作为服务运行时,带有git构建的CruiseControl.Net失败

时间:2012-01-27 15:16:27

标签: .net git cruisecontrol.net

我们最近切换到git来满足源控制需求。我们一直在使用cruisecontrol.net。我在cc.net配置文件中创建了新任务,并使用git源控制块进行设置。我确保我可以通过命令行在ssh上使用git。当我从控制台运行时,我的cruisecontrol.net工作正常。

然而,只要我将cruisecontrol.net作为服务运行,git fetch(或克隆)就会超时。我尝试创建一个任务来在计算机启动时运行cc.exe进程,但结果与作为服务运行的结果相同。我已经在cc.net文档中设置环境变量以使用git,我已经设置了ssh并为bitbucket保存了主机等。该服务与我在控制台中运行的用户一样运行。

如何让git作为服务运行?

示例构建脚本

<project name="******* Develop" queue="Q1" queuePriority="1">
    <webURL>http://cc.*******two.co.uk/server/local/project/*******Develop/ViewLatestBuildReport.aspx</webURL>
    <workingDirectory>D:\Integration\********* Develop\WorkingDirectory</workingDirectory>
    <artifactDirectory>D:\Integration\********* Develop\Artifacts</artifactDirectory>
    <modificationDelaySeconds>10</modificationDelaySeconds>
    <triggers>
      <intervalTrigger seconds="600" name="continuous" />
    </triggers>
    <sourcecontrol type="git">
        <repository>git@bitbucket.org:*******/*******-2.git</repository>
        <branch>develop</branch>
        <autoGetSource>true</autoGetSource>
        <executable>C:\Program Files\Git\cmd\git.cmd</executable>
        <tagOnSuccess>false</tagOnSuccess>
        <commitBuildModifications>false</commitBuildModifications>
        <commitUntrackedFiles>false</commitUntrackedFiles>
        <committerName>*******BuildServer</committerName>
        <committerEMail>devserver@*******.co.uk</committerEMail>
        <workingDirectory>D:\Integration\*******Develop\WorkingDirectory</workingDirectory>
        <timeout>300000</timeout>
    </sourcecontrol>
    <tasks>
        <exec>
            <executable>e2prebuild.bat</executable>
            <baseDirectory>D:\Integration\*******Develop\Scripts</baseDirectory>
            <buildTimeoutSeconds>30</buildTimeoutSeconds>
        </exec>
        <msbuild>
            <executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
            <workingDirectory>D:\Integration\*******Develop\WorkingDirectory</workingDirectory>
            <projectFile>*********.sln</projectFile>
            <buildArgs>/p:Configuration=Release /v:diag</buildArgs>
            <targets>Build</targets>
            <timeout>900</timeout>
            <logger>D:\CruiseControl\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
        </msbuild>
        <exec>
            <executable>e2deploy.bat</executable>
            <baseDirectory>D:\Integration\*******Develop\Scripts</baseDirectory>
            <buildTimeoutSeconds>900</buildTimeoutSeconds>
        </exec>
        <exec>
            <executable>ecrondeploy.bat</executable>
            <baseDirectory>D:\Integration\*******Develop\Scripts</baseDirectory>
            <buildTimeoutSeconds>900</buildTimeoutSeconds>
        </exec>
    </tasks>
  </project>

在构建失败时从CC.Net登录

<cruisecontrol project="********* Develop">
  <request source="*********DEV" buildCondition="ForceBuild">Build (ForceBuild) triggered from *********DEV</request>
  <parameters>
    <parameter name="$CCNetArtifactDirectory" value="D:\Integration\********* Develop\Artifacts" />
    <parameter name="$CCNetBuildCondition" value="ForceBuild" />
    <parameter name="$CCNetBuildDate" value="2012-01-26" />
    <parameter name="$CCNetBuildTime" value="15:10:27" />
    <parameter name="$CCNetFailureUsers" value="System.Collections.ArrayList" />
    <parameter name="$CCNetIntegrationStatus" value="Unknown" />
    <parameter name="$CCNetLabel" value="3" />
    <parameter name="$CCNetLastIntegrationStatus" value="Success" />
    <parameter name="$CCNetListenerFile" value="D:\Integration\********* Develop\Artifacts\********* Develop_ListenFile.xml" />
    <parameter name="$CCNetModifyingUsers" value="System.Collections.ArrayList" />
    <parameter name="$CCNetNumericLabel" value="3" />
    <parameter name="$CCNetProject" value="********* Develop" />
    <parameter name="$CCNetProjectUrl" value="http://cc.*********.co.uk/server/local/project/*********Develop/ViewLatestBuildReport.aspx" />
    <parameter name="$CCNetRequestSource" value="*********DEV" />
    <parameter name="$CCNetUser" value="" />
    <parameter name="$CCNetWorkingDirectory" value="D:\Integration\********* Develop\WorkingDirectory" />
  </parameters>
  <modifications />
  <integrationProperties>
    <CCNetArtifactDirectory>D:\Integration\********* Develop\Artifacts</CCNetArtifactDirectory>
    <CCNetBuildCondition>ForceBuild</CCNetBuildCondition>
    <CCNetBuildDate>2012-01-26</CCNetBuildDate>
    <CCNetBuildTime>15:10:27</CCNetBuildTime>
    <CCNetFailureUsers />
    <CCNetIntegrationStatus>Exception</CCNetIntegrationStatus>
    <CCNetLabel>3</CCNetLabel>
    <CCNetLastIntegrationStatus>Success</CCNetLastIntegrationStatus>
    <CCNetListenerFile>D:\Integration\********* Develop\Artifacts\********* Develop_ListenFile.xml</CCNetListenerFile>
    <CCNetModifyingUsers />
    <CCNetNumericLabel>3</CCNetNumericLabel>
    <CCNetProject>********* Develop</CCNetProject>
    <CCNetProjectUrl>http://cc.*********.co.uk/server/local/project/*********Develop/ViewLatestBuildReport.aspx</CCNetProjectUrl>
    <CCNetRequestSource>*********DEV</CCNetRequestSource>
    <CCNetWorkingDirectory>D:\Integration\********* Develop\WorkingDirectory</CCNetWorkingDirectory>
    <LastIntegrationStatus>Success</LastIntegrationStatus>
    <LastSuccessfulIntegrationLabel>3</LastSuccessfulIntegrationLabel>
    <LastModificationDate>25/01/2012 15:15:29</LastModificationDate>
  </integrationProperties>
  <build date="2012-01-26 15:10:27" buildtime="00:05:01" buildcondition="ForceBuild" />
  <exception><![CDATA[ThoughtWorks.CruiseControl.Core.CruiseControlException: Source control operation has timed out.
   at ThoughtWorks.CruiseControl.Core.Sourcecontrol.ProcessSourceControl.Execute(ProcessInfo processInfo)
   at ThoughtWorks.CruiseControl.Core.Sourcecontrol.Git.GitFetch(IIntegrationResult result)
   at ThoughtWorks.CruiseControl.Core.Sourcecontrol.Git.CreateUpateLocalRepository(IIntegrationResult result)
   at ThoughtWorks.CruiseControl.Core.Sourcecontrol.Git.GetModifications(IIntegrationResult from, IIntegrationResult to)
   at ThoughtWorks.CruiseControl.Core.Sourcecontrol.QuietPeriod.GetModifications(ISourceControl sourceControl, IIntegrationResult lastBuild, IIntegrationResult thisBuild)
   at ThoughtWorks.CruiseControl.Core.IntegrationRunner.GetModifications(IIntegrationResult from, IIntegrationResult to)
   at ThoughtWorks.CruiseControl.Core.IntegrationRunner.Integrate(IntegrationRequest request)]]></exception>
</cruisecontrol>

CruiseControl.net版本:1.5.7256.1

3 个答案:

答案 0 :(得分:3)

当我经历过这种情况时,一直是因为git提示在控制台输入。 CCNet服务通常以更高的权限(比常规登录用户)运行,因此尝试以管理员身份运行Git Bash,执行git clone ...,并确保没有提示您必须在控制台旁路。另外,请仔细检查您是否真的以服务用户身份运行;所有SSH密钥和已知主机都按用户保存。

答案 1 :(得分:1)

我使用Cruise Control遇到了类似的问题,但对我来说,我正在运行一个批处理文件来执行我的所有git语句,这些语句超时但仅在从Cruise Control触发时。以用户身份登录并手动执行批处理文件,没有任何问题。我的批处理文件正在运行一个构建脚本,其中包括启动一些git bash shell脚本以执行我的git命令的步骤。

例如,我的构建过程将执行此语句:

"c:\program files\git\git.exe" --login -i "myshellscript.sh"

然后shell脚本会执行一些逻辑来清理目录,检查指定的分支或散列键,推送注释等。这会在执行第一次获取后挂起,这是因为git bash中的$ HOME目录不同当CC作为服务启动时以及何时使用远程桌面进行测试之间。为了确认,我在“myshellscript.sh”

中添加了一个声明
echo $HOME

这返回的路径与我作为桌面用户登录时的路径不同,因此没有找到我的ssh密钥文件,这导致任何git fetch挂起等待用户响应。我发现this guide用于设置便携式git,它包括手动指定自己的家庭配置文件的步骤。为此,找到安装git的位置,并编辑etc \ profile文件。改变行:

# normalize HOME to unix path
HOME="$(cd "$HOME" ; pwd)" 

要:

# normalize HOME to unix path
HOME="/c/Build Server/MyProfile"
HOME="$(cd "$HOME" ; pwd)"

答案 2 :(得分:0)

在布拉德利的帮助下,我意识到尽管用户名是相同的,我的服务仍在不同的配置文件中运行。以管理员身份运行git bash(但仍然是同一个用户)向我显示我的〜/文件夹位于windows \ system32 \ systemprofile。我刚刚将之前创建的.ssh配置文件夹复制到该文件夹​​中,现在看起来工作正常。