Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Team City git push hangs the build

Tags:

git

teamcity

I have an issue with Team City 8.0.3 (build 27540) hanging on a secondary build step that pushes changes to a remote repository. I can't locate any information that gives me insight into what's wrong.

The VCS is setup via SSH, using the default private key, and checkout mode is set to automatically on agent.

Source is checked into a "repositoryPath" via a checkout rule.

Build step runs git commands from the working directory of "repositoryPath".

Here is the build log from the second step that runs the commit:

Step 2/2: Commit dlls (Command Line) (running for 1m:09s)
[16:46:51][Step 2/2] Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script5045114249582743499.cmd
[16:46:51][Step 2/2] in directory: C:\TeamCity\buildAgent\work\8df15579b05cdb68\repositoryPath
[16:46:51][Step 2/2] [master 9fa24ba] Teamcity update
[16:46:51][Step 2/2]  1 file changed, 0 insertions(+), 0 deletions(-)
*** HANGS HERE ***

Here is the git push command line step:

"%env.TEAMCITY_GIT_PATH%" add .
"%env.TEAMCITY_GIT_PATH%" commit -m "Teamcity update"
"%env.TEAMCITY_GIT_PATH%" push

If I drop to the the Team City work directory, I notice that the commit has taken, but hasn't been pushed. If I attempt a git push, it goes off without any problem.

I would be happy to furnish further detail if it would help.

like image 305
Jeff Mitchell Avatar asked Jan 13 '23 14:01

Jeff Mitchell


2 Answers

TeamCity uses cmd.exe to run your git commands. As this stackoverflow answer says, Git relies on the shell scripting, which is not available inside cmd.

Try to call msysgit's bash to execute a bash script with required git commands.

like image 105
Nikita Skvortsov Avatar answered Jan 16 '23 02:01

Nikita Skvortsov


As a comment above also suggests, the root cause is probably git asking for a password, which is never supplied by TeamCity.

Try configuring git so that it doesn't request a password (e.g. setup ssh keys/use wincred/git-credential-winstore).

Or if you're using GitHub and are are happy to put your password in the url (as suggested by this post):

git push https://username:[email protected]/username/repository.git
like image 35
Andy Joiner Avatar answered Jan 16 '23 01:01

Andy Joiner