Using the source repository to trigger the build of a plan is one of the available methods for triggering builds in Bamboo.
"変更がコミットされるとリポジトリがビルドをトリガーする" という設定は、Bamboo サーバーの負荷を最小限に抑えるという利点があります。ただし、ソース リポジトリが Bamboo サーバーにイベントを発生させるように設定されている必要があります (設定した計画は "リッスン" します)。
変更がコミットされるとリポジトリがビルドをトリガーするように設定するには、次の 2 つの変更が必要です。
全体のプロセスは、リポジトリにコミットすると、コミット後のメッセージが Bamboo に送信されるというものです。Bamboo は、リポジトリに未ビルドの変更がないかチェックすることで応答します。変更が見つかると、Bamboo はビルドをトリガーします。
1. ソース リポジトリを設定する
コミット後のイベント メッセージを Bamboo に送信するようにソース コード管理システムのリポジトリを設定します。送信されるメッセージで、このリポジトリを使用する計画の構築を開始するよう Bamboo に伝えます。
- Copy the scripts to your repository. If you are using the Bamboo distribution, the scripts are located in the
/scriptsfolder of your Bamboo Installation Directory. You can also download the scripts by following this link. Use the same SVN script for Git. - リポジトリが実行されているオペレーティング システムによっては、スクリプトの編集が必要になることがあります。スクリプトは、「
wget」が「/usr/bin/」にあると仮定します。これが自分のリポジトリに当てはまらない場合 (たとえば Solaris 10 では/usr/sfw/bin/にある)、スクリプトを編集して、「/usr/bin/」を適切な場所に変更します。 - Bamboo を実行しているユーザーが、スクリプトを実行する適切なファイル権限を持っていることを確認します。つまり、スクリプトは非 root ユーザーでも実行可能でなければなりません。
2. コミット後のメッセージに応答するように Bamboo を設定する
始める前に
- リポジトリの更新がないときにビルドをトリガーする — ローカル作業コピーとリポジトリ コピーのリビジョン番号が同じ場合、Bamboo はビルド トリガーを無視します。ビルド トリガーをテストするときは、ローカル作業コピーが最新バージョンでないことをご確認ください。最新バージョンになっていると、Bamboo はそれ以上のアクションを実行しません。
- 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.
コードのチェック インでビルドをトリガーするように Bamboo を設定する方法は次のとおりです。
- ダッシュボードをクリックし、すべてのプラン タブをクリックします。
- リスト内で計画を見つけ、編集アイコンをクリックして、計画の設定ページを表示します。
- [トリガー] タブをクリックしてから、既存のトリガーまたは [トリガーを追加] をクリックします。
- オプションで、トリガーの説明を入力します。
- [トリガーのタイプ] > [Repository triggers the build when changes are committed (変更がコミットされるとリポジトリがビルドをトリガー)] を選択します。
- Bamboo は、[ソース リポジトリ] タブで以前に設定したとおり、計画に利用可能なリポジトリを表示します。このトリガーが適用されるリポジトリを選択します。
リポジトリのプライマリ IP アドレス以外からのコミット後メッセージに対して Bamboo をトリガーさせる場合のみ、[Trigger IP Addresses (トリガー IP アドレス)] に IP アドレスを入力します。
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 the current outbound IP addresses can be found at Access Bitbucket from Behind a Firewall
- [Save Trigger (トリガーを保存)] をクリックします。
スクリーンショット: ビルド戦略 — 変更がコミットされるとリポジトリがビルドをトリガーする

15 Comments
Anonymous
Oct 31, 2012What does
JIRA-MAINandJIRA-BRANCHmean in the git post-receive example?Anonymous
Oct 31, 2012Ah, it's explained in the CVS example:
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.
Anonymous
Jan 10, 2014That is the
BUILD-KEY. The BUILD-KEYis the key of the Bamboo plan to be executed (from Configuring source code management triggers for Subversion).The easiest way I found to find the BUILD-KEY is to: login to bamboo -> select the project -> click to edit the plan you want to trigger. Now look at the url. It should look something like http://<host>:<port>/chain/admin/config/defaultStages.action?buildKey=XX-XXX where XX-XXX is what you want to replace JIRA-MAIN in the example with.
Anonymous
Dec 21, 2012Is anybody has the Git post-receive script to trigger bamboo build? I don't seem to see it on the Bamboo installation folder. There scripts for SVN, CVS, and Perforce, but no Git.
PiotrA
Dec 21, 2012Which script are you talking about? If you need postCommitBuildTrigger.sh then you can steal it from the SVN folder and re-use it for Git's post-receive hook. Unless I'm mistaken and it won't work - what problem exactly are you encountering?
Per Franck
Feb 19, 2013can someone please just explain what to add to updateAndBuild.action?buildKey=
is it simply the plan name? it doesn't seem to work.
I entered http://ciserver:8085/updateAndBuild.action?buildKey=TEST-TEST1 and i get a blank page with a bamboo header (dashboard, authors, reports) nothing happens internally. no build is starting.
PiotrA
Feb 19, 2013Hm... it could be that your Bamboo server is ignoring the request because it comes from a non-whitelisted IP. Can you double check your configuration, whether you have "Trigger IP Addresses" field configured properly (it should have IP of the server from which the call will be made - either your machine (if you do the manual attempt with web browser) or the machine hosting Hg repository (if you manage to plug wget/curl/other_tool into Mercurial hook on Windows)).
Per Franck
Feb 19, 2013I had the IP set up, but when i remove it from bamboo, i get the same page but now it says my IP isn't valid. i added it back in and the blank page appears again. I then tried again, but now (whoda thunk?) i added some changes to the repo first, and the build starts. would be nice with some feedback though.
Anonymous
Mar 05, 2013I am also facing the same issue and and bamboo returns a blank page when I hit http://<host>:<port>/build/updateAndBuild.action?buildKey=<ABC>
What changes I need to do in order to be working?
Peter Kahn
Mar 18, 2013So, when the script springs the trigger, bamboo checks the repository for commits as-of-yet-unbuilt. When testing the trigger, I must commit a change first or bamboo will appear to do nothing. It is really checking with the repo to see if there is work to do.
paulwatson
Mar 18, 2013Correct, Peter. I'll add your comment into the page.
David Kowis
Jun 14, 2013How does one trigger the build now with the REST API? The remoting API has been removed, and the docs there point towards teh REST API.
Thanks, David
Anonymous
Sept 25, 2013How can you allow a trigger from a subnet of addresses? I know how to do multiple IPs, but I'd rather have a subnet of IPs allowable.
Ben Cheney
Nov 21, 2013One thing which took me ages to figure out... you need to have anonymous access enabled for the plan you're trying to trigger the build for. If you don't, the script will just receive a login page in response and nothing else will happen.
aMarcus
Nov 21, 2013This actually not the case. Depending on which service you have configured to notify Bamboo, you can use your credentials over http to authenticate using basic authentication.