4
votes

I have set up a build agent on Linux SUSE 11 for teamCity and installed a git client on the agent. So each git commit triggers new build in TeamCity via TeamCity Agent.

Note that "Server-side checkout" mode works fine with build agent which means Enterprise TeamCity and agent are able to talk. Not sure but I guess that there are issue with proxy settings. Proxy settings are in: ~/.bashrc and /etc/profile

If I log into build agent's box and manually perform: git clone someProject it works fine. However, if Enterprise Team City does the same, an error occurs:

Log from web interface of Enterprise Team City:

[13:16:26]Checking for changes
[13:16:32]Publishing internal artifacts
[13:16:32]Clearing temporary directory: /opt/buildAgent/temp/buildTmp
[13:16:32]Checkout directory: /opt/buildAgent/work/413442a249b8bad8
[13:16:32]Updating sources: agent side checkout (3m:11s)
[13:16:32][Updating sources] Using vcs information from server. Reason: no revision information for buildtype my-project:master: build and checkout directory /opt/buildAgent/work/413442a249b8bad8 on agent
[13:16:32][Updating sources] Will perform clean checkout. Reason: Checkout directory was cleaned up with errors
[13:16:32][Updating sources] Cleaning /opt/buildAgent/work/413442a249b8bad8
[13:16:33][Updating sources] VCS Root: [15116-12]Team::VCS_1 (3m:10s)
[13:16:33][VCS Root: [15116-12]_Team::VCS_1] revision: dff43c329bc0495efd66ffcfd4fddd26e66e4a50
[13:16:33][VCS Root: [15116-12]_Team::VCS_1] Cleaning /opt/buildAgent/work/413442a249b8bad8
[13:16:33][VCS Root: [15116-12]_Team::VCS_1] The .git directory is missing in '/opt/buildAgent/work/413442a249b8bad8'. Running 'git init'...
[13:16:33][VCS Root: [15116-12]_Team::VCS_1] Commit 'dff43c329bc0495efd66ffcfd4fddd26e66e4a50' is not found in repository. Running 'git fetch'...
[13:19:44]
[Updating sources] Failed to perform checkout on agent: '/usr/bin/git -c core.askpass=/opt/buildAgent/temp/buildTmp/pass102793096014863366 fetch --progress origin +refs/heads/master:refs/remotes/origin/master' command failed.
stderr: error: Failed connect to stash.mySite.com:8081; Operation now in progress while accessing https://[email protected]:8081/scm//myProject.git/info/refs?service=git-upload-pack
fatal: HTTP request failed
[13:19:44]Publishing internal artifacts
[13:19:44]Build failed to start. Artifacts will not be published for this build
[13:19:46]Build finished

Log from BuildAgent at \logs\teamcity-agent.log:

[2014-05-29 07:55:04,204]   INFO -    jetbrains.buildServer.AGENT - ===================================================
[2014-05-29 07:55:04,204]   INFO -    jetbrains.buildServer.AGENT - Starting build buildId = 1258156, buildTypeId=bt10493
[2014-05-29 07:55:04,206]   INFO - mpl$TeamCitySpringSubConatiner - Refreshing SubContext: running build context id=1258156: startup date [Thu May 29 07:55:04 BST 2014]; parent: jetbrains.buildServer.agent.AgentMain2$2@6cc06bf7
[2014-05-29 07:55:04,411]   INFO - uildStages.BuildStagesExecutor - Call stage jetbrains.buildServer.agent.impl.buildStages.startStages.LogAgentParametersStage
[2014-05-29 07:55:04,413]   INFO - uildStages.BuildStagesExecutor - Call stage jetbrains.buildServer.agent.impl.buildStages.startStages.ClearExpiredBuildWorkingDirectoriesStage
[2014-05-29 07:55:04,413]   INFO - uildStages.BuildStagesExecutor - Call stage jetbrains.buildServer.agent.impl.buildStages.startStages.UpdateDirectoryMapStage
[2014-05-29 07:55:04,429]   INFO - uildStages.BuildStagesExecutor - Call stage jetbrains.buildServer.agent.impl.buildStages.startStages.RegisterPropertiesFileNamesStage
[2014-05-29 07:55:04,431]   INFO - uildStages.BuildStagesExecutor - Call stage jetbrains.buildServer.agent.impl.buildStages.startStages.EnableBuildStopStage
[2014-05-29 07:55:04,431]   INFO - uildStages.BuildStagesExecutor - Call stage jetbrains.buildServer.agent.impl.buildStages.startStages.FireBuildStartedStage
[2014-05-29 07:55:04,436]   INFO - uildServer.swabra.SwabraLogger - Swabra cleanup is disabled
[2014-05-29 07:55:04,436]   INFO - uildStages.BuildStagesExecutor - Call stage jetbrains.buildServer.agent.impl.buildStages.startStages.CleanAgentTempDirectoryStage
[2014-05-29 07:55:04,437]   INFO - rectories.DirectoryCleanerImpl - Move directory /opt/buildAgent/temp/agentTmp to /opt/buildAgent/temp/.old/agentTmp_17 for cleaning
[2014-05-29 07:55:04,437]   INFO - uildStages.BuildStagesExecutor - Call stage jetbrains.buildServer.agent.impl.buildStages.startStages.CreateAgentTempDirectoryStage
[2014-05-29 07:55:04,437]   INFO - uildStages.BuildStagesExecutor - Call stage jetbrains.buildServer.agent.impl.buildStages.startStages.PublishBuildPropertiesStage
[2014-05-29 07:55:04,442]   INFO - ernalArtifactsProcessingLogger - Publishing artifacts process started
[2014-05-29 07:55:04,442]   INFO - ernalArtifactsProcessingLogger - Start: Searching for artifacts to publish in [/opt/buildAgent/temp/agentTmp/build.start.properties.gz=>.teamcity/properties]
[2014-05-29 07:55:04,442]   INFO - ernalArtifactsProcessingLogger - Done:  Searching for artifacts to publish, found [1] file
[2014-05-29 07:55:04,442]   INFO - ernalArtifactsProcessingLogger - Start: Pre-processing artifacts if needed (archiving)
[2014-05-29 07:55:04,442]   INFO - ernalArtifactsProcessingLogger - Done: Pre-processing artifacts if needed (archiving)
[2014-05-29 07:55:04,442]   INFO - uildStages.BuildStagesExecutor - Call stage jetbrains.buildServer.agent.impl.buildStages.startStages.CleanBuildTempDirectoryStage
[2014-05-29 07:55:04,443]   INFO - s.CleanBuildTempDirectoryStage - Clearing temporary directory: /opt/buildAgent/temp/buildTmp
[2014-05-29 07:55:04,443]   INFO - rectories.DirectoryCleanerImpl - Move directory /opt/buildAgent/temp/buildTmp to /opt/buildAgent/temp/.old/buildTmp_17 for cleaning
[2014-05-29 07:55:04,443]   INFO - uildStages.BuildStagesExecutor - Call stage jetbrains.buildServer.agent.impl.buildStages.startStages.CreateBuildTempDirectoryStage
[2014-05-29 07:55:04,444]   INFO - uildStages.BuildStagesExecutor - Call stage jetbrains.buildServer.agent.impl.buildStages.startStages.CreateCheckoutDirectoryStage
[2014-05-29 07:55:04,445]   INFO - ace.DirectoryCleanerForceClean - Free disk space under directory /opt/buildAgent/temp is 3.77 GB, required 3 GB.
[2014-05-29 07:55:04,445]   INFO - uildStages.BuildStagesExecutor - Call stage jetbrains.buildServer.agent.impl.buildStages.startStages.CleanGeneratedFilesStage
[2014-05-29 07:55:04,445]   INFO - uildStages.BuildStagesExecutor - Call stage jetbrains.buildServer.agent.impl.buildStages.startStages.LogCheckoutDirectoryStage
[2014-05-29 07:55:04,446]   INFO -    jetbrains.buildServer.AGENT - Checkout directory: /opt/buildAgent/work/413442a249b8bad8
[2014-05-29 07:55:04,446]   INFO - uildStages.BuildStagesExecutor - Call stage jetbrains.buildServer.agent.impl.patch.UpdateSourcesFromAgent
[2014-05-29 07:55:04,446]   INFO - ch.UpdateSourcesBuildStageBase - Updating sources: agent side checkout
[2014-05-29 07:55:04,447]   INFO -    jetbrains.buildServer.AGENT - No revision information for 413442a249b8bad8.xml on agent
[2014-05-29 07:55:04,448]   INFO - pl.patch.ProjectSourcesOnAgent - Will perform clean checkout. Reason: [ROOT_DIRECTORY_WAS_CLEANED_UP_WITH_ERRORS]
[2014-05-29 07:55:04,448]   INFO - pl.patch.ProjectSourcesOnAgent - Cleaning /opt/buildAgent/work/413442a249b8bad8
[2014-05-29 07:55:04,448]   INFO - rectories.DirectoryCleanerImpl - Move directory /opt/buildAgent/work/413442a249b8bad8 to /opt/buildAgent/work/.old/413442a249b8bad8_17 for cleaning
[2014-05-29 07:55:04,449]   INFO -    jetbrains.buildServer.AGENT - Patch downloaded for build with id 1258156
[2014-05-29 07:55:05,491]   INFO - ernalArtifactsProcessingLogger - Start: Publishing files using WebPublisher
[2014-05-29 07:55:05,517]   INFO - ernalArtifactsProcessingLogger - Start: Publishing files using ArtifactsCachePublisher
[2014-05-29 07:55:05,563]   INFO - ernalArtifactsProcessingLogger - Done publishing artifacts to '.teamcity/properties', using 'WebPublisher', total files published: 1
[2014-05-29 07:55:05,563]   INFO - ernalArtifactsProcessingLogger - Done publishing artifacts to '.teamcity/properties', using 'ArtifactsCachePublisher', total files published: 1
[2014-05-29 07:55:05,563]   INFO - ernalArtifactsProcessingLogger - Done: Publishing files
[2014-05-29 07:55:05,730]   INFO - ernalArtifactsProcessingLogger - Publishing artifacts process finished
[2014-05-29 07:55:06,052]   INFO -    jetbrains.buildServer.AGENT - Attempting to mark checkoutdir 413442a249b8bad8 for build 1258156 dirty
[2014-05-29 07:55:06,052]   INFO -    jetbrains.buildServer.AGENT - Number of vcsRootEntries: [VcsRootEntry[VcsSettings["[15116-12]_MYTEAM::GIT_VCS" {internal id=27876, properties: [agentCleanFilesPolicy=ALL_UNTRACKED; agentCleanPolicy=ON_BRANCH_CHANGE; authMethod=PASSWORD; branch=refs/heads/master; ignoreKnownHosts=true; secure:password=*****; submoduleCheckout=CHECKOUT; teamcity:vcsRootName=[15116-12]_MYTEAM::GIT_VCS; url=https://stash.mySite.com:8081/scm/myProject.git; username=build_user; usernameStyle=USERID; vcs=jetbrains.git; ]}; Checkout rules: ]]]
[2014-05-29 07:55:06,052]   INFO -    jetbrains.buildServer.AGENT - Recording vcs state. C: dff43c329bc0495efd66ffcfd4fddd26e66e4a50, Id: 5085_jetbrains.git_-210835581203928646_60553, CR: =>

[2014-05-29 07:55:06,052]   INFO -    jetbrains.buildServer.AGENT - Moved configuration file 413442a249b8bad8.xml to old
[2014-05-29 07:55:06,052]   WARN -    jetbrains.buildServer.AGENT - new file 413442a249b8bad8.xml.new exists. Previous build might have not finished successfully
[2014-05-29 07:55:06,053]   INFO -    jetbrains.buildServer.AGENT - Stored new configuration file 413442a249b8bad8.xml
[2014-05-29 07:55:06,054]   INFO - pl.patch.ProjectSourcesOnAgent - Updating sources for root id=27876; name=[15116-12]_MYTEAM::GIT_VCS; revision: dff43c329bc0495efd66ffcfd4fddd26e66e4a50
[2014-05-29 07:55:06,072]   INFO - gers.vcs.git.agent.UpdaterImpl - Starting update of root [15116-12]_MYTEAM::GIT_VCS in /opt/buildAgent/work/413442a249b8bad8 to revision dff43c329bc0495efd66ffcfd4fddd26e66e4a50
[2014-05-29 07:55:06,073]   INFO - gers.vcs.git.agent.UpdaterImpl - Cleaning /opt/buildAgent/work/413442a249b8bad8
[2014-05-29 07:55:06,074]   INFO - rectories.DirectoryCleanerImpl - Move directory /opt/buildAgent/work/413442a249b8bad8 to /opt/buildAgent/work/.old/413442a249b8bad8_18 for cleaning
[2014-05-29 07:58:16,562]   WARN - ch.UpdateSourcesBuildStageBase - Error while checkout on agent: '/usr/bin/git -c core.askpass=/opt/buildAgent/temp/buildTmp/pass4372765007199018345 fetch --progress origin +refs/heads/master:refs/remotes/origin/master' command failed.
stderr: error: Failed connect to stash.mySite.com:8081; Operation now in progress while accessing https://[email protected]:8081/scm/myProject.git/info/refs?service=git-upload-pack
fatal: HTTP request failed
jetbrains.buildServer.vcs.VcsException: '/usr/bin/git -c core.askpass=/opt/buildAgent/temp/buildTmp/pass4372765007199018345 fetch --progress origin +refs/heads/master:refs/remotes/origin/master' command failed.
stderr: error: Failed connect to stash.mySite.com:8081; Operation now in progress while accessing https://[email protected]:8081/scm/myProject.git/info/refs?service=git-upload-pack
fatal: HTTP request failed
        at jetbrains.buildServer.buildTriggers.vcs.git.agent.command.impl.CommandUtil.commandFailed(CommandUtil.java:64)
        at jetbrains.buildServer.buildTriggers.vcs.git.agent.command.impl.CommandUtil.checkCommandFailed(CommandUtil.java:41)
        at jetbrains.buildServer.buildTriggers.vcs.git.agent.command.impl.CommandUtil.runCommand(CommandUtil.java:109)
        at jetbrains.buildServer.buildTriggers.vcs.git.agent.GitCommandLine.run(GitCommandLine.java:83)
        at jetbrains.buildServer.buildTriggers.vcs.git.agent.command.impl.FetchCommandImpl.call(FetchCommandImpl.java:102)
        at jetbrains.buildServer.buildTriggers.vcs.git.agent.UpdaterImpl.fetch(UpdaterImpl.java:496)
        at jetbrains.buildServer.buildTriggers.vcs.git.agent.UpdaterImpl.fetchDefaultBranch(UpdaterImpl.java:452)
        at jetbrains.buildServer.buildTriggers.vcs.git.agent.UpdaterImpl.fetchFromOriginalRepository(UpdaterImpl.java:441)
        at jetbrains.buildServer.buildTriggers.vcs.git.agent.UpdaterImpl.ensureCommitLoaded(UpdaterImpl.java:432)
        at jetbrains.buildServer.buildTriggers.vcs.git.agent.UpdaterImpl.doFetch(UpdaterImpl.java:427)
        at jetbrains.buildServer.buildTriggers.vcs.git.agent.UpdaterImpl.doUpdate(UpdaterImpl.java:109)
        at jetbrains.buildServer.buildTriggers.vcs.git.agent.UpdaterImpl.update(UpdaterImpl.java:102)
        at jetbrains.buildServer.buildTriggers.vcs.git.agent.GitAgentVcsSupport.updateSources(GitAgentVcsSupport.java:90)
        at jetbrains.buildServer.agent.impl.patch.ProjectSourcesOnAgent$1.run(ProjectSourcesOnAgent.java:252)
        at java.lang.Thread.run(Thread.java:744)

VCS root settings:

Type of VCS: Git
Fetch URL: https://stash.mySite.com:8081/scm/myProject.git
Push URL: Empty
Default branch: refs/heads/master
Authentication method: Password
Test connection: ok

Please note that I use https-connection for conversation between git-client and Stash.

Command as in the above logs of TeamCity that works on the agent manually: buildAgent:~/cd /opt/buildAgent/work/413442a249b8bad8 buildAgent::/opt/buildAgent/work/413442a249b8bad8>/usr/bin/git -c core.askpass=/opt/buildAgent/temp/buildTmp/pass4372765007199018345 fetch --progress origin +refs/heads/master:refs/remotes/origin/master

Result Connected

 * [new tag]         myProject-1.2 -> myProject-1.2
 * [new tag]         myProject-1.3 -> myProject-1.3
 * [new tag]         myProject-1.4 -> myProject-1.4
 * Closing connection #0

How to fix it?

1
Did you try manually running the same command that TeamCity runs, in the same directory and as the same user?Dave Schweisguth
The message Failed connect to stash.mySite.com:8081 indicates the agent can't connect to the source (Atlassian Stash?). That doesn't look like an https connection - make sure your VCS root is using the correct URL?SteveChapman
It would assist if you post both of the VCS root URL, and the command you're using that works on the agentSteveChapman
Yes, this is Atlassian stash. stash.mySite.com:8081 - that's https actually as can be seen in the logs.Ivan Voroshilin
Dave: as far as I know TeamCity talks to buildAgent via http and the agent itself runs git commands.Ivan Voroshilin

1 Answers

2
votes

I resolved the issue. We use Stash, thus on build-agent I should have added to ~/.gitconfig a user for Stash.

[user]
        name = MyUserName
        email = myEmail

In team-city fetch URL-path to the git repo on Stash should also have this user, e.g.:

https:[email protected]:8081