Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run git command from teamcity buildstep

Tags:

git

teamcity

I want to pull the latest changes from the remote and I have a step

git fetch origin +refs/changes/*:refs/remotes/origin/changes/*

configured as a command line by calling git from C:\Program Files (x86)\Git\cmd\Git

However, when teamcity runs the command, it just waits and waits and waits..

Starting: C:\Windows\system32\cmd.exe /s /c ""c:\Program Files (x86)\Git\cmd\git" fetch origin"
[11:54:31]in directory: C:\BuildAgent\work\99b8cd174ffcc354
[11:55:04]Process exited with code 1

The exit code 1 at 11:55 is me stopping the build as it took more than a minute to run the fetch command. I have waited even longer.

Any help is appreciated.

like image 974
Gentoo Avatar asked May 23 '26 10:05

Gentoo


1 Answers

Pavel commented:

To debug issues like this you should login to the agent machine and execute exactly the same command under the user who started agent process. Most likely it will hang too.

We were using git push in one of our build steps and it was hanging on the build server. What you might find is that you need to tell git that origin remote is trusted and that it should always be trusted. It comes up in the console when you first try to connect to a remote host that is not trusted.

Once you have done this once on one build agent you should be able to copy the known_hosts file from the build agents git folder between all the build agents.

like image 132
Bronumski Avatar answered May 26 '26 01:05

Bronumski