Repository triggers the build when changes are committed

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 method 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.

If you're using Bitbucket Cloud, we recommend that you configure build triggering with webhooks. See Triggering a Bamboo build from Bitbucket Cloud using Webhooks.

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 Cloud, select to expand...

Add the Bamboo webhook to your repository in Bitbucket Cloud. 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 Bitbucket Server, select to expand...

When you create a plan that uses a linked Bitbucket Server repository, Bamboo uses the Bitbucket repository triggers the build when changes are committed trigger option by default.

For Git, select to expand...

Learn how to setup Remote repository triggering in Bamboo when using Git repositories: Git Repository - Remote Trigger. Edit the Git repository's .git/hooks/post-receive trigger file, for example with the following:


/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 is the project key 
  • BRANCH or MAIN are the plan key

For Git, use the SVN postCommitBuildTrigger.sh script. See below for more information about the scripts.

For Mercurial, select to expand...

 Edit the Hg repository's .hg/hgrc settings, for example with the following:


[hooks]
commit = /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 is the project key 
  • BRANCH or MAIN are the plan key
See below for more information about the scripts.
For Subversion, select to expand...

If you are using a remote SVN server, copy file "atlassian-bamboo/repositoryScripts/svn-triggers/postCommitBuildTrigger.sh" (.py for Windows installations) located in the Bamboo install directory to the SVN repository .../hook/post-commit folder so that the post CommitBuildTrigger file is accessible from the post-commit trigger file.

Edit the Subversion repository's hooks/post-commit trigger file, for example with the following:

/path/to/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 is the project key 
  • BRANCH or MAIN are the plan key

See below for more information about the scripts. Also, refer to Configuring source code management triggers for Subversion.

For CVS, select to expand...

 Edit two files in the CVSROOT module: commitinfo and loginfo.

  • For commitinfo, add a line like this:

    ^jira(/|$)  /pathto/preCommit.sh

    where jira is your module.

  • For loginfo, you can add a line. For example:

    ^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 is the project key 
    • BRANCH or MAIN are the plan key
See below for more information about the scripts. Please refer to Configuring source code management triggers for Subversion.


  • You can download the scripts using this link. Use the same SVN script for Git. Copy the scripts to your repository. The scripts can also be found in the /scripts folder of your Bamboo Installation Directory

  • 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 has appropriate file permissions to execute the scripts, i.e. the scripts should be executable by non-root user(s).

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 Cloud 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:

  1. From the Bamboo dashboard select Builds > All build plans.
  2. Locate the plan in the list and select the edit icon () to display the plan's configuration pages.
  3. Select the Triggers tab, then Add trigger.
  4. Select Remote trigger.
  5. Bamboo displays the available repositories for the plan, as previously configured on the Source repositories tab. Optionally, enter a trigger description. Select the repositories that this trigger should apply to.
  6. 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.

    If you use a Mercurial or Git repository then you must type the IP address of your repository host in Trigger IP addresses. For Bitbucket Cloud the current outbound IP addresses can be found at Access Bitbucket Cloud from Behind a Firewall.

  7. Select Save trigger.

Remote trigger configuration screen 


Last modified on Aug 7, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.