Git Source Control Block

Source Control Plugin for CruiseControl.NET that talks to git.


Available from version 1.5


Minimalist Example

1<sourcecontrol type="git">
2  <repository>git://</repository>

Full Example

 1<sourcecontrol type="git">
 2  <repository>git://</repository>
 3  <branch>master</branch>
 4  <autoGetSource>true</autoGetSource>
 5  <fetchSubmodules>true</fetchSubmodules>
 6  <executable>git</executable>
 7  <tagOnSuccess>false</tagOnSuccess>
 8  <commitBuildModifications>false</commitBuildModifications>
 9  <commitUntrackedFiles>false</commitUntrackedFiles>
10  <tagCommitMessage>CCNet Build {0}</tagCommitMessage>
11  <tagNameFormat>CCNet-Build-{0}</tagNameFormat>
12  <committerName>Max Mustermann</committerName>
13  <committerEMail></committerEMail>
14  <workingDirectory>c:\build\rails</workingDirectory>
15  <timeout>60000</timeout>

Configuration Elements

Element Description Type Required Default Version
type The type of source control block. String - must be git Yes n/a 1.5
autoGetSource Whether to fetch the updates from the repository and checkout the branch for a particular build. Boolean No true 1.5
branch Remote repository branch to monitor and checkout. String No master 1.5
cleanUntrackedFiles Remove untracked files from the working tree Boolean No true 1.8.5
commitBuildModifications Indicates that all modifications during the build process should be committed before tagging. This requires 'tagOnSuccess ' to be set to 'true'. Boolean No false 1.5
committerEMail Used to set the "" configuration setting in the local repository. Required for the 'tagOnSuccess ' feature. String No None 1.5
committerName Used to set the "" configuration setting in the local repository. Required for the 'tagOnSuccess ' feature. String No None 1.5
commitUntrackedFiles Indicates that files created during the build process should be committed before tagging. This requires 'commitBuildModifications' and 'tagOnSuccess ' to be set to 'true'. Boolean No false 1.5
dynamicValues The dynamic values to use for the source control block. Dynamic Values array No None 1.5
executable The location of the Git executable. String No git 1.5
fetchSubmodules Indicates that CruiseControl.NET should initialize and fetch git submodules. Boolean No false 1.6
issueUrlBuilder Converts the comment (or parts from it) into an url pointing to the issue for this build. See IssueUrlBuilder for more details. IssueUrlBuilder No None 15
maxAmountOfModificationsToFetch Maximum amount of commit logs to fetch when checking the history. 0 Means no limit, X means limit to that number Int32 No 100 1.8.5
repository The url to the remote repository. String Yes false 1.5
tagCommitMessage Format string for the commit message of each tag. \{0\} is the placeholder for the current build label. String No CCNet Build \{0\} 1.5
tagNameFormat Format string for the name of each tag. Make sure you're only using allowed characters. \{0\} is the placeholder for the current build label. String No CCNet-Build-\{0\} 1.5
tagOnSuccess Indicates that the repository should be tagged if the build succeeds. Boolean No false 1.5
timeout Sets the timeout period for the source control operation. See Timeout Configuration for details. Timeout Configuration No 10 minutes 15
workingDirectory The directory containing the local git repository. String No Project Working Directory 1.5


How does this work?

Local repository initialization

The Git Source Control Block will check whenever the specified working directory exist or not. If it does not exist a "git clone" command is issued to create and setup the local repository. Also the configuration settings "" and "" for the local repository will be set with "git config" if both are provided. If 'fetchSubmodules' is set to 'true' git submodules will be initialized.

If the working directory exists but is not a git repository (e.g. the .git directory is missing) it will be deleted and the "git clone" and configuration instructions described above will be issued.

If the working directory is already the root of an existing git repository no initialization is done.

Checking for modifications

Once the repository is initialized the "git fetch origin" command is issued to fetch the remote changes. Next, "git log $LastIntegrationCommit..origin/$BranchName --name-status -c", is issued to get a list of commits and their changes, where $LastIntegrationCommit is the commit which was checked out the last time an integration was run. If the project has not yet been integrated, a "git log origin/$BranchName --name-status -c" command is issued instead.

Getting the source

Once Cruise Control.NET has modifications detected and the 'autoGetSource' property is set to 'true' the "git checkout -f origin/$NameOfTheBranch" command is issued. Also the "git clean -f -d -x" command to get a clean working copy to start a new build. If 'fetchSubmodules' is set to 'true' git submodules will be fetched and updated.

Tagging a successful build

After a successful build and when the 'tagOnSuccess' property is set to 'true' the "git -a -m 'tagCommitMessage' tag 'build label'" command is issued and a "git push origin tag 'name of the tag'" to push the tag to the remote repository.

If 'commitBuildModifications' is set to 'true' then all modified files will be committed before tagging with a "git commit --all --allow-empty -m 'tagCommitMessage'". If you also set 'commitUntrackedFiles' to 'true' all untracked files that are not ignored by .gitignores will be added to the git index before committing and tagging with a "git add --all" command.

Using Git on Windows

Download and install the latest version of msysgit.

* Point the "executable" property to the git.cmd file (e.g. C:\Program Files\Git\cmd\git.cmd)  
* Or set the "path" environment variable to the "bin" directory of your msysgit instalation (e.g. C:\Program Files\Git\bin), the "HOME" environment variable to "%USERPROFILE%" and the "PLINK_PROTOCOL" environment variable to "ssh".  


Using Git on Unix (CruiseControl.NET with Mono)

Make sure that you've the latest Git installed via your distributions packet manager and that git and all its required applications are in $PATH.

Additional Information

The default port git uses is 9418. Git over SSH uses port 22 by default. Make sure that your firewall is set up to handle this.

Automatically Generated

Documentation generated on Monday, 26 May 2014 at 7:18:02 AM