Call Git Command From Build Step Stuck

Hi,

I am relatively new to TeamCity, but have been tasked with creating a gated check-in build that is configured to use a GIT repository hosted on BitBucket, where if the build successfully completes, it pushes to another repository on BitBucket.

I have created the SSH key on the VM where TeamCity is installed and have uploaded to the public key to BitBucket and TeamCity web dashboard.

I have tried a number of different approaches, but have been unsuccessful. When ever it gets to the build step to push to the remote repository, it is stuck calling the following:

call %env.TEAMCITY_GIT_PATH% push origin master --verbose

I have tried the following:

- VCS Root using the authentication method: Uploaded Key and Default Private Key
- VCS Checkout mode: Automattically on Agent
- Checkout directory: Automattically
- Clean Build: Checked
-.ssh private key is sitting under both the TeamCity and TeamCityService account with the following config file containing:

 Host bitbucket.org

 User git

 Hostname bitbucket.org

 PreferredAuthentications publickey

 StrictHostKeyChecking no

 IdentityFile ~/.ssh/id_rsa

I tried running the git commands on the VM through GitBash and they work fine.

Any suggestions would be helpful.

Thanks,
Bruce

6 comments
Comment actions Permalink

Hi,

Does push command (the same as used by TeamCity) work if you run it via console on agent machine in working directory under the same user as agent running?
If you use Uploaded key, you need to upload private key through TeamCity Web UI.

0
Comment actions Permalink

Hi Alina,

Thanks for your reply.

I have tried that and found everything to work ok when running under the agent from the command line using Git Bash.

I have tried both options in TeamCity, so uploading the private key and using the default key, with neither working. Both approaches seem to trigger the build to be in a stuck mode.

Many Thanks,
Bruce

0
Comment actions Permalink

I had this kind of problem in the past, and the reason was that SSH was asking something on the console. Typical examples: passphrase and host confirmation, when the host key is not known yet.
This is affected by the environment variables (HOME...), because they will make SSH to look for its files at a location or another. That would explain why it works interactively and not from TeamCity, since the environment initialization path is typically different.

0
Comment actions Permalink

Hi Olivier,

Thanks for your response.

I decided not to add a passphrase to the key to try and avoid any prompt, while executing the git command.

I will take a look at setting the HOME enviroment variable. Is there anywhere specific this should be done?

Thanks,
Bruce

0
Comment actions Permalink

Hi Bruce,

Just to make it clear, I don't know if it's the cause of your problem :)

Before modifying anything, I would try to find out if it's the case, for instance by running the ProcessMonitor while the build is running, to see what Git is doing and what configuration files are read.

0
Comment actions Permalink

GitBush can have it's own environment configured. Can you please try to run this command using console?
Just to make things clear. If you run git command from script it does not use keys uploaded to TeamCity. Keys configured for VCS root are used only by TeamCity to perform checkout.

0

Please sign in to leave a comment.