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

Unknown macro: {spacejump}

of Bamboo, or visit the latest Bamboo documentation.

The Amazon Elastic Block Store (EBS) provides 'EBS volumes' which can attach to EC2 instances. EBS volumes (and the 'EBS snapshots' created from these volumes) provide persistent storage for your elastic instances.

Bamboo ジョブの構築に必要な比較的静的なリソース(ソースコードのチェックアウトおよび Maven リポジトリ アーティファクトなど)がある場合は、これらを EBS ボリュームに追加することができます。このボリュームから、EBS スナップショットを作成することができます。これは、指定された時点での EBS ボリュームの「状態」を効果的に記録することができます。

After setting up an EBS snapshot, you can then associate it with an elastic image configuration. When this elastic image is started:

  • its elastic instance will be started, along with the EBS volume (derived from the EBS snapshot associated with the elastic image) and
  • this EBS volume will be attached to this elastic instance
    (info) any build resources (added to the EBS volume prior to creating its snapshot) will be available to this elastic instance.

Elastic Bamboo と一緒に EBS を使うべき理由
エラスティック インスタンスはステートレスなので、そのインスタンス上で実行されるエラスティック エージェントもステートレスです。したがって、エラスティック インスタンスが同じイメージから再起動される場合は常に次のことが該当します。

  • エラスティック エージェントが外部から取得しなければならないリソース (Maven のリポジトリ アーティファクトなど) はすべて、全体をそのままダウンロードする必要があります。
  • 新しいジョブが作成されたら、エラスティック エージェントによる全体のチェックアウトを行う必要があります。

EBS を使用すると、こうした外部リソースを EBS ボリュームとスナップショットに保存できるため、イメージからエラスティック インスタンスを起動するたびにダウンロードしたり、ソースコードをチェックアウトしたりする必要がなくなります。ジョブがそのようなリソースのダウンロードに大きく依存している場合や、毎回クリーン ビルドを実行していない場合、EBS を使用することでビルド時間が大幅に改善される可能性があります。

Additionally, the EBS provides an easy mechanism for customising elastic agents, rather than you having to create a custom elastic image from scratch (with your own elastic agent capabilities). For example, you could upload files and scripts to your EBS volume that would install resources such as PostgreSQL databases for your elastic agents, which will be available when the agent's elastic instance is started.

このページの内容

最初の EBS スナップショットを作成する

最初の EBS スナップショットを作成する方法は次のとおりです。

  1. Download Amazon Web Services (AWS) account identifiers to your Bamboo server — You will need to store the AWS private key file and certificate file on your Bamboo server to use Elastic Bamboo with EBS. If you haven't downloaded an AWS private key file or certificate file to your Bamboo server yet, please see Generating your AWS Private Key File and Certificate File for instructions.
  2. Update your Bamboo configuration settings with the location of the AWS account identifier files you have downloaded. This will ensure that these files are uploaded to any new elastic instances started. See the Elastic Instance Settings section on the Configuring Elastic Bamboo for instructions (you will need to update the Upload AWS account identifiers to new elastic instances (mandatory if EBS Snapshot ID specified) checkbox and Account Private Key File and Account Certificate File fields described on this page).
  3. Start a single elastic instance via Bamboo. See Starting an elastic instance for instructions.
  4. Access your elastic instance via SSH (see Accessing an elastic instance for instructions).
  5. As root user, follow the steps below to create an EBS volume and attach it to the elastic instance (steps a & b), upload content to the EBS volume (step c & d), and generate the snapshot (step e & f):
    (info) All the scripts mentioned below are available in /opt/bamboo-elastic-agent/bin on Bamboo stock images. You can also download them from here (choose the latest version). 
    1. createInitialVolume.sh <ボリュームのサイズ> を実行します。このスクリプトでは、EBS ボリューム (<ボリュームのサイズ> はそのボリュームの大きさ) を作成し、ボリュームをアタッチして、エラスティック インスタンスにマウントします。たとえば、createInitialVolume.sh 100 の場合は、100GB EBS ボリュームを作成し、それをエラスティック インスタンスに添付してマウントします。
    2. Run rewarmEbsSnapshot.sh — This script sets up the standard structure for Elastic Bamboo on the EBS volume. The directories and files for this standard volume structure are detailed in the Important EBS Directories and Files section below.
    3. (optional) Populate your EBS volume — Your EBS volume can now be populated with any files and scripts that you wish to make available to the elastic instances that use the EBS volume. For example, you may want to upload maven repository data, source code, scripts and files to install databases on your elastic agents, etc. You must upload your files to the /mnt/bamboo-ebs folder or its subfolders, if you want them to be included in the snapshot. We recommend that you read Populating your EBS volume for guidelines on how to populate your EBS volume effectively.
      (info) The EBS volume is attached to the elastic instance, so accessing your elastic instance via SSH will give you full access to the EBS volume (see Important EBS Directories and Files below).
    4. アップロードされたすべてのコンテンツの所有者が bamboo:bamboo であることを確認します。コマンド chown -R bamboo:bamboo <ファイル名> を実行すると、ファイルの所有者を設定できます。
    5. killall java コマンドを実行します。このコマンドでは、エージェント プロセスなど、インスタンス上のすべてのプロセスを強制終了するため、ボリュームをアンマウントしてスナップショットを作成できます。
    6. Run generateSnapshot.sh — This script unmounts and detaches the volume, before creating a snapshot based on the volume. The time taken to create the snapshot will vary depending on the amount of content that you have uploaded to the EBS volume. The Snapshot ID for the snapshot will be available in the logs for the elastic instance. See Accessing an Elastic Instance for instructions on how to access the logs for your elastic instance.
      (info) The device can not unmount if any terminals are currently in the mounted volume.
  6. Shut down your elastic instance. See Shutting down an elastic instance for instructions.

EBS スナップショットを使用するようにエラスティック イメージを設定する

EBS スナップショットの設定が終了したら、最後のステップは、スナップショットの詳細をエラスティック イメージ設定に追加することです。これにより、そのイメージから起動されるすべてのインスタンスに EBS ボリュームがアタッチされます。さまざまなスナップショットを別々のエラスティック イメージ設定に関連付けることができます。

EBS スナップショットを使用するように Elastic Bamboo を設定する方法は次のとおりです。

  1. Determine the Snapshot ID of the EBS snapshot you have just created. The Snapshot ID should be recorded in the logs of the elastic instance you created it on. You can also view your EBS snapshots in the AWS Console by clicking the Snapshots menu item.



  2. Click the  icon in the Bamboo header and choose Overview.
  3. 左側のナビゲーション列で [Image Configuration (イメージ設定)] ([Elastic Bamboo] の下) をクリックします。 
  4. Click Edit in the 'Operations' column for the elastic image configuration that you would like to add your EBS snapshot to. The 'Edit Elastic Image Configuration - <imagename>' screen will display (see screenshot below).


  5. [Automatically attach an Amazon Elastic Block Store (EBS) volume to new elastic instances (Amazon Elastic Block Store (EBS) ボリュームを新しいエラスティック インスタンスに自動的にアタッチ)] を選択します。 
  6. [EBS Snapshot ID (EBS スナップショット ID)] フィールドに EBS スナップショットのスナップショット ID を入力します。
  7. [Save (保存)] をクリックします。指定したスナップショットから新しい EBS ボリュームが作成され、そのイメージから起動されたすべての新しいエラスティック インスタンスにアタッチされます。

EBS スナップショットを更新する

現在 Elastic Bamboo で EBS を使用していて、スナップショットの更新が必要になった場合は、次の手順に従ってください。この手順は、新しい EBS スナップショットを作成する手順に似ています。

EBS スナップショットを更新するには、次の手順に従います。

  1. Start a single elastic instance via Bamboo. See Starting an elastic instance for instructions.
  2. (optional) Run a build on the elastic agent of the instance to populate the attached EBS volume. We recommend that you read Populating your EBS volume for guidelines on how to populate your EBS volume effectively.
  3. Access your elastic instance via SSH (see Accessing an elastic instance for instructions) and do the following:
    (info) All the scripts described below are bundled with Bamboo.
    1. (オプション) 追加のコンテンツがあれば、アタッチされた EBS ボリュームにセキュア コピー (SCP) でアップロードします。ファイルをスナップショットに含める場合は、/mnt/bamboo-ebs フォルダまたはそのサブフォルダにファイルをアップロードする必要があります。
    2. killall java を実行します。このコマンドでは、すべてのエージェント プロセスを強制終了し、マウントされたボリュームを使用していない状態にします。
    3. jps -vl を実行します。このコマンドでは、インスタンスで実行されているすべての Java プロセスのリストを表示します。実行中の Java プロセスは存在しないはずです。
    4. Run generateSnapshot.sh — This script unmounts and detaches the volume, before creating a snapshot based on the volume.
      (info) The device can not unmount if any terminals are currently in the mounted volume.
    5. Check the elastic instance logs for the Snapshot ID of the snapshot you just created. See Accessing an Elastic Instance for instructions on how to access the logs for your elastic instance.
    6. Update the new Snapshot ID in your Elastic Bamboo configuration, as described in Configuring an Elastic Image to use an EBS snapshot above.

重要な EBS ディレクトリとファイル

慣例により、Bamboo では EBS デバイスは /dev/sdh でアタッチされます。これは /mnt/bamboo-ebs にマウントされます。標準構造のコンテンツは次のとおりです。

  • bin/customiseInstance.sh - This script is run on startup of an elastic instance. We recommend that you do not customise this script, as it is overwritten when rewarmEbsSnapshot.sh is run.
  • bin/customise-extras.sh - This script is run on startup of an elastic instance as the root (as opposed to being run as the Bamboo user). This script is safe to customise, as it will never be overwritten. You can customise this script to automate processes such as setting up your database, move files to custom locations on the instance, etc.
  • profile-extras.sh - このスクリプトは、(ルートとして実行されるのではなく) Bamboo ユーザーで実行されるプロファイルに追加されます。これは環境変数を設定するのに便利です。
  • bamboo-agent/bamboo-agent.cfg.xml - この設定ファイルでは、ビルド作業ディレクトリを EBS ボリューム上のビルド作業ディレクトリを指すように変更します。
  • bamboo-agent/build-dir - これはビルド作業ディレクトリです。
  • maven/build.properties - このプロパティ ファイルは、エラスティック インスタンスの起動時に /home/bamboo にコピーされます。Maven 1 の既定のリポジトリは /mnt/bamboo-ebs/maven/.maven を指します。
  • maven/.m2/settings.xml - この設定ファイルは、エラスティック インスタンスの起動時に /home/bamboo/.m2 にコピーされます。Maven 2 の既定のリポジトリは /mnt/bamboo-ebs/maven/.m2/repository を指します。
  • tmp-extras - このディレクトリのコンテンツは、エラスティック インスタンスの起動時に /tmp にコピーされます。