Pulling or pushing to github from a TeamCity agent
Hello.
I use a TeamCity build agent to build code. When I built it I change a file, commit it and want to push it back. I don't want to use my password in the Build Step's command line. So, I use the SSH Exec runner type. I made a key, uploaded the public one to github and the private one to TeamCity. I see my id_rsa key is used in VCS root and in the Build agent.
I create a VCS Root: Type of VCS: Git, Fetch URL: ssh://git@github.com/repo_name.git, Username: git, Auth method: Uploaded key, Username: git, Uploaded key: id_rsa. It works, the repo clones well.
Futher I want to update another branch by hand, commit to it and push it. So, I create the build step: Authentification method: Uploaded key Target: github.com Username: git Select key: id_rsa Commands: git fetch ssh://git@github.com/repo_name.git master. Here I tried different urls, but nothing works with error:
Step 1/6: Update (SSH Exec)
Please sign in to leave a comment.
Hi Dgordenin in your build step you are doing a git fetch but first shouldn't you do a git clone ssh://git@github.com/repo_name.git
Depending on your checkout mode (https://www.jetbrains.com/help/teamcity/vcs-checkout-mode.html#) only the agent side option will actually do a clone on the agent for you, where you can perform further git actions on that cloned repo. If you use a checkout mode like server side it only transfers the files from your git repo.
Hi, Dylan Munyard .
My VCS checkout mode is "Always checkout files on agent".
I set my build step "SSH Exec" to "git clone ssh://git@github.com/repo_name.git".But still have the following error:
Step 1/6: Update (SSH Exec)
Dgordenin I think I see the problem, it says in the message "Executing commands on host [github.com]" which I think means SSH Exec step is for executing remote commands, not as a 'SSH wrapper'. I think what you want is the 'SSH agent' feature instead, this one is a 'Build Feature' so open it from your build settings and add it and select your key.
Then add a build step which executes on the command line and try now git clone ...
Dylan,
I have a Build feature "SSH agent" with uploaded key id_rsa.
Which type of build step should i create? I have a "SSH Exec" - result is the error above. I have "Command line" - result is error:
I'm on Windows, so I have a PowerShell step:
In the build output I have:
15:01:27
Cloning into 'E:\BuildAgent1\work\7c1f1231fdb4fc7d/AddOnPacks/Schema.Core/dev'...
15:01:28
Warning: Permanently added 'hostname,IP' (RSA) to the list of known hosts.
Do you have the "Command Line" build step?
VCS checkout mode "Always checkout files on agent"?
Yes, I have just set up a build that does a VCS checkout on the agent then does a git clone.
I think you are making progress, you were using the wrong build step before now you have a different error: Host key verification failed. Seems like a Git issue now - not TC - but maybe a TC official will help if you believe it's a TeamCity problem.
Thank you, finally moved the ssh keys to the /root/.ssh and got it working.