Using the source repository to trigger the build of a plan is one of the available methods for triggering builds in Bamboo.
"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:
The overall process is: a commit to the repository causes a post-commit message to be sent to Bamboo. Bamboo responds by checking the repository for unbuilt changes. If changes are found, Bamboo triggers a build.
1. Configuring your source repository
Configure your source code management system's repository to send post-commit event messages to Bamboo. These messages tell Bamboo to begin building the plans that use this repository.
For Bitbucket, click here to expand...
Add the Bamboo hook to your repository in Bitbucket. No further action is necessary on your local repository. Each push of new commits in to Bitbucket will trigger the build based on your configuration.
For Stash, click here to expand...
When you create a plan that uses a linked Stash repository, with Stash 3.1 and later, Bamboo uses the 'Stash repository triggers the build when changes are committed' trigger option by default.
For Git, click here to expand...
Edit the Git respository's .git/hooks/post-receive
trigger file with something like:
For Git, use the SVN postCommitBuildTrigger.sh
script. See below for more information about the scripts.
For Mercurial, click here to expand...
Edit the Hg respository's .hg/hgrc
settings file with something like:
See below for more information about the scripts.
For Subversion, click here to expand...
If you are using a remote SVN server, copy file "atlassian-bamboo/repositoryScripts/svn-triggers/postCommitBuildTrigger.sh" to the SVN repository .../hook/post-commit folder so that the postCommitBuildTrigger.sh file can be accessible from post-commit
trigger file.
Edit the Subversion repository's hooks/post-commit
trigger file with something like:
See below for more information about the scripts. Please refer to Configuring source code management triggers for Subversion.
For Perforce, click here to expand...
Add the script as a change-commit trigger.
See below for more information about the scripts.
For CVS, click here to expand...
Edit two files in the CVSROOT module: commitinfo
and loginfo
.
For commitinfo
, add a line like this:
where "jira" is your module.
For loginfo
, add a line like this:
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.
2. Configuring Bamboo to respond to post-commit messages
Before you begin:
- Triggering a build when there is no repository update — Bamboo will ignore build triggers if the local working copy and the repository copy have the same revision numbers. When testing your build triggers, ensure that the local working copy is not the latest version - if this is the case, Bamboo will take no further action.
- If you're using the Bitbucket Bamboo post-push hook, ensure that the user you are using to authenticate triggering the build has the 'build' permission on the plan you are attempting to trigger.
To configure Bamboo to trigger a build on code check in:
- Click Dashboard and then the All Plans tab.
- Locate the plan in the list and click the edit icon to display the plan's configuration pages.
- Click the Triggers tab, then click either an existing trigger or Add Trigger.
- Optionally, enter a trigger description.
- Choose Trigger type > Repository triggers the build when changes are committed.
- Bamboo displays the available repositories for the plan, as previously configured on the Source Repositories tab. Choose the repositories that this trigger should apply to.
Only enter an IP address in Trigger IP Addresses if you want Bamboo to trigger on post-commit messages from other than the primary IP address for the repository.
- Click Save Trigger.
Screenshot: Build Strategy – repository triggers the build when changes are committed