Documentation for Bamboo 4.3.x. Documentation for other versions of Bamboo is available too.

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 つの変更が必要です。

  1. Configuring your source repository.
  2. Configuring Bamboo to trigger a build on code check in.

1. ソース リポジトリを設定する

To configure your source repository:

コミット後のイベント メッセージを Bamboo に送信するようにソース コード管理システムのリポジトリを設定します。送信されるメッセージで、このリポジトリを使用する計画の構築を開始するよう Bamboo に伝えます。

CVSROOT モジュール内の 2 つのファイル (commitinfologinfo) を編集します。

  • commitinfo の場合、次のような行を追加します。

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

    where "jira" is your module.

  • loginfo の場合、次のような行を追加します。

    ^jira(/|$) /pathto/postCommitBuildTrigger.sh %{} http://bambooserver JIRA-MAIN JIRA-BRANCH
    

    ここで、JIRA-MAIN と JIRA-BRANCH はトリガーする Bamboo 計画、JIRA はプロジェクト キー、BRANCH または MAIN は計画キーです。

Please refer to Configuring source code management triggers for Subversion.

リモート SVN サーバーを使用している場合は、「atlassian-bamboo/repositoryScripts/svn-triggers/postCommitBuildTrigger.sh」ファイルを SVN リポジトリの「.../hook/post-commit」フォルダーにコピーします。post-commit トリガー ファイルから「postCommitBuildTrigger.sh」ファイルにアクセスできるようにするためです。

Subversion リポジトリの hooks/post-commit トリガー ファイルを次のように編集します。

/pathto/postCommitBuildTrigger.sh http://bambooserver JIRA-MAIN JIRA-BRANCH

Please refer to Configuring source code management triggers for Subversion.

 スクリプトを変更コミットのトリガーとして追加します。

triggerName change-commit //myDepot/... "/usr/local/bin/postCommitBuildTrigger.sh http://bambooServer/ MYPLAN-DEFAULT"

Edit the Hg respository's .hg/hgrc settings file with something like:

[hooks]
changegroup.update = /pathto/postCommitBuildTrigger.sh http://bambooserver JIRA-MAIN JIRA-BRANCH

 Edit the Git respository's .git/hooks/post-receive trigger file with something like:

/pathto/postCommitBuildTrigger.sh http://bambooserver JIRA-MAIN JIRA-BRANCH
  1. 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.
  2. リポジトリが実行されているオペレーティング システムによっては、スクリプトの編集が必要になることがあります。スクリプトは、「wget」が「/usr/bin/」にあると仮定します。これが自分のリポジトリに当てはまらない場合 (たとえば Solaris 10 では /usr/sfw/bin/ にある)、スクリプトを編集して、「/usr/bin/」を適切な場所に変更します。
  3. Bamboo を実行しているユーザーが、スクリプトを実行する適切なファイル権限を持っていることを確認します。つまり、スクリプトは非 root ユーザーでも実行可能でなければなりません。
  4. Enable Bamboo's remote API so that the scripts can use Bamboo's REST-style remote API to access Bamboo's data.

2. Configuring Bamboo to trigger a build on code check in

始める前に

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

コードのチェック インでビルドをトリガーするように Bamboo を設定する方法は次のとおりです。

  1. ダッシュボードをクリックし、すべてのプラン タブをクリックします。
  2. リスト内で計画を見つけ、編集アイコンをクリックして、計画の設定ページを表示します。
  3. [トリガー] タブをクリックしてから、既存のトリガーまたは [トリガーを追加] をクリックします。
  4. オプションで、トリガーの説明を入力します。
  5. [トリガーのタイプ] > [Repository triggers the build when changes are committed (変更がコミットされるとリポジトリがビルドをトリガー)] を選択します。
  6. Bamboo は、[ソース リポジトリ] タブで以前に設定したとおり、計画に利用可能なリポジトリを表示します。このトリガーが適用されるリポジトリを選択します。
  7. Only enter an IP address in Trigger IP Addresses if you want Bamboo to receive post-commit notifications 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.

  8. [Save Trigger (トリガーを保存)] をクリックします。

スクリーンショット: ビルド戦略 — 変更がコミットされるとリポジトリがビルドをトリガーする