ClearCarbon
ClearCarbon

Reputation: 459

CruiseControl.Net with git build fails when running as a service

We recently switched to git for our source control needs. We have been using cruisecontrol.net for some time. I've created new tasks within the cc.net config file and set the up with a git source control block. I've made sure I can use git over ssh via the command line. I have cruisecontrol.net working fine when I run it from the console.

However as soon as I run cruisecontrol.net as a service the git fetch (or clone) times out. I tried creating a task to run the cc.exe process on computer startup but the results are the same as running as a service. I've set the environment variables in the cc.net documentation for using git and I've setup ssh and saved the host etc for bitbucket. The service is running as the same user I'm running in the console.

Any ideas how to get git running as a service?

Example Build Script

<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>[email protected]:*******/*******-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>

Log From CC.Net on failed build

<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 Version: 1.5.7256.1

Upvotes: 4

Views: 2962

Answers (3)

Mike Wilson
Mike Wilson

Reputation: 692

I ran into a similar issue using Cruise Control, but for me I was running a batch file to execute all of my git statements, which was timing out but only when triggered from Cruise Control. Logging in as a user and executing the batch file manually worked without any issues. My batch file was running a build script, which included steps to launch some git bash shell scripts to execute my git commands.

For example, my build process would execute this statement:

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

The shell script would then perform some logic to clean the directories, checkout the specified branch or hash key, push notes, etc. This would hang after doing the first fetch, and it's because the $HOME directory in git bash was different between when CC would launch as a service and from when I would test using remote desktop. To confirm, I added a statement to "myshellscript.sh"

echo $HOME

This was returning a different path than when I logged in as a desktop user, so it was not finding my ssh key files, which was causing any git fetch to hang waiting for a user response. I found this guide for setting up a portable git, and it includes steps to specify your own home profile manually. To do this, find where git was installed to, and edit the etc\profile file. Change the lines:

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

To:

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

Upvotes: 1

Bradley Grainger
Bradley Grainger

Reputation: 28162

When I've experienced this, it has been because git is prompting for input at the console. The CCNet service usually runs with higher privileges (than a regular logged-on user), so try running Git Bash as administrator, execute git clone ..., and make sure there are no prompts you have to bypass at the console. Also, double-check that you're really running as the service user; all the SSH keys and known hosts are saved per-user.

Upvotes: 3

ClearCarbon
ClearCarbon

Reputation: 459

Ok with the help of Bradley I realised that my service was running in a different profile despite the username being the same. Running git bash as an administrator (but still the same user) showed me that my ~/ folder was at windows\system32\systemprofile. I just copied the .ssh profile folder that I had created earlier into that folder, seems to be working fine now.

Upvotes: 0

Related Questions