我已经在Linux SUSE 11上为TeamCity设置了一个构建代理,并在代理上安装了git客户端。因此,每次进行git提交都会通过TeamCity代理触发新的构建。
需要注意的是,“服务器端检出”模式与构建代理一起正常工作,这意味着Enterprise TeamCity和代理能够通信。但我不确定是否存在代理设置问题。代理设置位于:~/.bashrc和/etc/profile中。
如果我登录到构建代理的系统并手动执行git clone someProject,则可以正常工作。然而,如果Enterprise TeamCity执行相同的操作,则会出现错误:
来自Enterprise TeamCity Web界面的日志:
请注意,我在git客户端和Stash之间的对话中使用https连接。
如何修复它?
需要注意的是,“服务器端检出”模式与构建代理一起正常工作,这意味着Enterprise TeamCity和代理能够通信。但我不确定是否存在代理设置问题。代理设置位于:~/.bashrc和/etc/profile中。
如果我登录到构建代理的系统并手动执行git clone someProject,则可以正常工作。然而,如果Enterprise TeamCity执行相同的操作,则会出现错误:
来自Enterprise TeamCity Web界面的日志:
[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://myUserName@stash.someThing.com: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
来自 \logs\teamcity-agent.log 的 BuildAgent 日志:
[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://build_user@stash.mySite.com: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://build_user@stash.mySite.com: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根设置:
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
请注意,我在git客户端和Stash之间的对话中使用https连接。
与TeamCity日志中手动工作的代理相同的命令: 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
结果 已连接
* [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
如何修复它?