変更がコミットされるとリポジトリがビルドをトリガーする

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

For Bitbucket Cloud, click here 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 into Bitbucket will trigger the build based on your configuration. 

For Bitbucket Server, click here 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.

Git の場合は、ここをクリックして展開...

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
ここで:
  • 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.

Mercurial の場合は、ここをクリックして展開...

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


[hooks]
commit = /pathto/postCommitBuildTrigger.sh http://bambooserver JIRA-MAIN JIRA-BRANCH
ここで:
  • 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
スクリプトの詳細は下記をご覧ください。
Subversion の場合は、ここをクリックして展開...

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 postCommitBuildTrigger 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
ここで:
  • 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.

Perforce の場合は、ここをクリックして展開...

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


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

スクリプトの詳細は下記をご覧ください。

CVS の場合は、ここをクリックして展開...

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

  • For commitinfo, add a line like this:

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

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

  • For loginfo , you can add a line, for example the following:

    ^jira(/|$) /pathto/postCommitBuildTrigger.sh %{} http://bambooserver JIRA-MAIN JIRA-BRANCH
    ここで:
    • 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 been 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.
  • Bamboo を実行しているユーザーが、スクリプトを実行する適切なファイル権限を持っていることを確認します。つまり、スクリプトは非 root ユーザーでも実行可能でなければなりません。

2. コミット後のメッセージに応答するように Bamboo を設定する

始める前に

  • リポジトリの更新がないときにビルドをトリガーする — ローカル作業コピーとリポジトリ コピーのリビジョン番号が同じ場合、Bamboo はビルド トリガーを無視します。ビルド トリガーをテストするときは、ローカル作業コピーが最新バージョンでないことをご確認ください。最新バージョンになっていると、Bamboo はそれ以上のアクションを実行しません。 
  • 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. 

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

  1. Click Dashboard and then the All Plans tab.
  2. リスト内で計画を見つけ、編集アイコンをクリックして、計画の設定ページを表示します。
  3. Click the Triggers tab, then Add Trigger.
  4. Choose Trigger type > Remote Trigger.
  5. オプションで、トリガーの説明を入力します。
  6. 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.
  7. 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

  8. Click Save Trigger.

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

 


最終更新日 2022 年 9 月 6 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.