"Repository triggers the build when changes are committed" has the advantage of placing minimal load on your Bamboo server. However, it requires that your source repository is configured to fire an event to the Bamboo server (which the configured Plan will 'listen for'). Configuring the repository to trigger the build when changes are committed requires two changes:
|
Step 1. Configuring your Source Repository
To configure your source repository:
- Configure your source code management system's repository to send post-commit event messages which tell Bamboo to commence building plans that use this repository. These event messages are sent whenever a code commit has occurred.
- For CVS, edit two files in the CVSROOT module:
commitinfo
andloginfo
.For
commitinfo
add a line like this:^jira(/|$) /pathto/preCommit.sh
where "jira" is your module.
For
loginfo
add a line like this:^jira(/|$) /pathto/postCommitBuildTrigger.sh %{} http://bambooserver JIRA-MAIN JIRA-BRANCH
where JIRA-MAIN and JIRA-BRANCH are the Bamboo plans that you would like to trigger, JIRA being the project key and BRANCH or MAIN being the plan key.
For Subversion, edit the Subversion respository's
hooks/post-commit
trigger file with something like:/pathto/postCommitBuildTrigger.sh http://bambooserver JIRA-MAIN JIRA-BRANCH
For Perforce, add the script as a change-commit trigger.
triggerName change-commit //myDepot/... "/usr/local/bin/postCommitBuildTrigger.sh http://bambooServer/ MYPLAN-DEFAULT"
For Mercurial, edit the Hg respository's
.hg/hgrc
settings file with something like:[hooks] changegroup.update = /pathto/postCommitBuildTrigger.sh http://bambooserver JIRA-MAIN JIRA-BRANCH
For Git, edit the Git respository's
.git/hooks/post-receive
trigger file with something like:/pathto/postCommitBuildTrigger.sh http://bambooserver JIRA-MAIN JIRA-BRANCH
For more details about configuring these message events for CVS and Subversion, please refer to Configuring Source Code Management Triggers for Subversion.
- For CVS, edit two files in the CVSROOT module:
- Copy the scripts to your repository. If you are using the Bamboo distribution, the scripts are located in the
/scripts
folder of your Bamboo Installation Directory. If you are using Bamboo EAR-WAR distribution, you can find them in the/repositoryScripts
folder. You can also download the scripts by following this link. - Depending on which operating system your repository is running on, you may need to edit the scripts. The scripts assume that '
wget
' is in '/usr/bin/
'; if this isn't the case for your repository (e.g. Solaris 10 has it in/usr/sfw/bin/
), edit the scripts and change '/usr/bin/
' to the appropriate location. - Ensure that the user which Bamboo is running as has appropriate file permissions to execute the scripts, i.e. the scripts should be executable by non-root user(s).
- Enable Bamboo's remote API so that the scripts can use Bamboo's REST-style remote API to access Bamboo's data.
Step 2. Configuring Bamboo to Trigger a Build on Code Check In
Before you begin:
- Triggering a build when there is no update — Bamboo will ignore the build triggers, if the local working copy and the repository copy have the same revision numbers. When testing your build triggers, please check that the local working copy is not the latest version - in which case, no further action will be taken.
To configure Bamboo to trigger a build on code check in:
- Navigate to the repository settings for desired Plan, as described on Specifying the Source Repository for a Plan.
- In the 'Build Strategy' field, select 'Repository triggers the build when changes are committed', which displays the 'Trigger IP Address' field (see screenshot below).
- If you want Bamboo to receive post-commit notifications from the repository's primary IP address, leave the 'Trigger IP Address' field blank. If you want Bamboo to receive post-commit notifications from a different IP address, type the IP address in the 'Trigger IP Address' field.
If you use Mercurial or Git repository then you must type the IP address of your repository host in the 'Trigger IP Address' field.
- Click the 'Save' button.
Screenshot above: Build Strategy: Repository triggers the build when changes are committed
Notes
Related Topics
Triggering a Plan Build when Code is Updated
Polling the Repository for Changes
Attachments:





