This page last changed on Jul 12, 2010 by ccnet-doc-gen.

Git Source Control Block

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

Version

Available from version 1.5

Examples

Minimalist Example
<sourcecontrol type="git">
  <repository>git://github.com/rails/rails.git</repository>
</sourcecontrol>
Full Example
<sourcecontrol type="git">
  <repository>git://github.com/rails/rails.git</repository>
  <branch>master</branch>
  <autoGetSource>true</autoGetSource>
  <fetchSubmodules>true</fetchSubmodules>
  <executable>git</executable>
  <tagOnSuccess>false</tagOnSuccess>
  <commitBuildModifications>false</commitBuildModifications>
  <commitUntrackedFiles>false</commitUntrackedFiles>
  <tagCommitMessage>CCNet Build {0}</tagCommitMessage>
  <tagNameFormat>CCNet-Build-{0}</tagNameFormat>
  <committerName>Max Mustermann</committerName>
  <committerEMail>max.mustermann@gmx.de</committerEMail>
  <workingDirectory>c:\build\rails</workingDirectory>
  <timeout>60000</timeout>
</sourcecontrol>

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
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 "user.email" configuration setting in the local repository. Required for the 'tagOnSuccess ' feature. String No None 1.5
committerName Used to set the "user.name" 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 1.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 1.5
workingDirectory The directory containing the local git repository. String No Project Working Directory 1.5

Notes

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 "user.name" and "user.email" 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
One the repository is initialized the "git fetch origin" command is issued to fetch the remote changes. In the next step the sha-1 hash of the specified remote branch and the local checkout is compared. If they're identical Cruise Control.NET will expect that there are no changes.
If the 2 sha-1 hashes are different a "git log --name-status -c --before=... --after=..." command is issued to get a list of the new commits and their changes.
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".

Homepage: http://code.google.com/p/msysgit/

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, 12 Jul 2010 at 4:23:19 PM
Using assembly version 1.6.7444.2

Document generated by Confluence on Jan 23, 2011 08:52