This is the documentation for Bamboo 5.8. View this page for the

Unknown macro: {spacejump}

of Bamboo, or visit the latest Bamboo documentation.

 

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 に伝えます。

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. 

 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.

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

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

Git の場合、SVN postCommitBuildTrigger.sh スクリプトを使用します。スクリプトの詳細は下記をご覧ください。

 Hg リポジトリの .hg/hgrc 設定ファイルを次のように編集します。

[hooks]
changegroup.update = /pathto/postCommitBuildTrigger.sh http://bambooserver JIRA-MAIN JIRA-BRANCH
スクリプトの詳細は下記をご覧ください。

リモート 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

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

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

triggerName change-commit //myDepot/... "/usr/local/bin/postCommitBuildTrigger.sh http://bambooServer/ MYPLAN-DEFAULT"
スクリプトの詳細は下記をご覧ください。

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

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

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

    ここで、「jira」は自分のモジュールです。

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

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

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

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 been found in the /scripts folder of your Bamboo Installation Directory

  • リポジトリが実行されているオペレーティング システムによっては、スクリプトの編集が必要になることがあります。スクリプトは、「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 を設定する方法は次のとおりです。

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

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

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