次にリストされたタスクを実行するには、リモート デスクトップ クライアントを使用して管理者アカウントでインスタンスにログインします。
ユーザー アカウントを設定する
Bamboo エージェントが使用するユーザー アカウントを作成します。アカウント名は自由に指定ください。次の例では Bamboo を使用しています。お使いのマシンで実行中のすべてのビルドが、このアカウントを使用します。一般ユーザーでかまいません (つまり、ビルドで必要な場合を除き、パワー ユーザーや管理者である必要はありません)。そのユーザーのパスワードを設定します。Windows イメージの既定のユーザーは、ユーザー名は Bamboo、パスワードは Atlassian1 です。
重要: 既定では、新たに作成されたユーザーに対しては、リモート ログイン権利を拒否する必要があります (それが望ましいからです)。念のため、そのユーザーの資格情報を使用してログインできないことを確認してください (資格情報を既定以外のものに変更していない限り)。
ファイアウォールを設定する
ポート 26224 で TCP 接続を受け入れるように Windows ファイアウォールを再設定します。Bamboo にはその他のインバウンド接続は必要ありません。
このポートの EC2 セキュリティ グループ設定の変更について心配する必要はありません。Bamboo が自動的にセットアップします。
必要なソフトウェアをインストールする
- Install a supported Oracle Java version.
- Download the latest version of agent installer zip from this this location (at the time this guide was written, the latest version was this). Unpack it to a desired location, we suggest using
C:\opt\bamboo-elastic-agentto match stock images distributed with Bamboo. - A batch file should launch with your Windows instance startup. In order to do this, use the Windows Task Scheduler (Start > Administrative Tools > Task Scheduler), and set up a new Action task of “Start a program" with the
<PATH TO YOUR BATCH FILE>as the Details:
Remember to select Run whether user is logged on or not in the “General” tab:
And appropriately define the Trigger task so that the agent starts up only after the network connection is up and running:
アカウントがバッチ ジョブとしてログインできる必要があるという警告がタスク マネージャーに表示されます。ユーザーに対して「Log on as batch job (バッチ ジョブとしてログオン)」ポリシーが設定されていることを確認してください。[コントロール パネル] > [管理ツール] > [ローカル セキュリティ ポリシー] の順に移動することでこのポリシーにアクセスできます。[ローカル セキュリティ ポリシー] ウィンドウで、[ローカル ポリシー] > [ユーザー権利の割り当て] > [Log on as batch job (バッチ ジョブとしてログオン)] をクリックします。
インスタンスで EBS の使用量を有効にする
Bamboo 5 以降では、Windows インスタンスでカスタム エラスティック ブロック ストレージを使用できるようになります。そのためには、インスタンスで SAN ポリシーを変更する必要があります。変更しないと、ディスクは「オフライン」状態で接続され、「the disk is offline because of policy set by an administrator (管理者が設定したポリシーにより、ディスクがオフラインになっています)」というステータス テキストが表示されます。
Diskpart ユーティリティを使用して SAN ポリシーを変更できます。Diskpart を実行して以下を入力します。
san policy=OnlineAll
and press Enter. You can then quit Diskpart; the new policy will now be active.
テスト
すべてが正しく設定されているかどうかを確認する最も簡単な方法は、Windows タスク スケジューラ ([スタート] > [管理ツール]> [タスク スケジューラ]) を使用して定義したタスクを実行することです。タスクを右クリックして [実行] を選択します。必ずタスク スケジューラを使用してスクリプトをテストしてください。スクリプトを手動で実行すると、管理者アカウントを使用することになりますが、これは正しい方法ではありません。
Look for the %USERPROFILE%/bamboo-elastic-agent.out file. If it exists and contains an error message stating that agent was not run within an EC2 instance started by Bamboo Server, you’ve successfully completed the customisation.
c:\opt\bamboo-elastic-agent\bin\prepareInstanceForSaving.bat を実行します。
インスタンスをバンドルします。新しいイメージの AMI ID をメモしておきます。
Bamboo からのイメージの起動
40 分以内に次の手順を完了しないと Bamboo によってインスタンスがシャット ダウンされるため、時間がなくなった場合は忘れずに作業内容を保存してください (つまり、中間イメージを作成します)。
Bamboo で、先ほど作成したイメージのイメージ構成を定義し、Bamboo から起動します。すべてうまくいけば、エージェントがインスタンスと一緒に起動します。次のステップが実行されます。
- 追加のディレクトリを作成して、/create /opt/bamboo-elastic-agent のディレクトリ構造を更新します。表示されれば、Java がそのマシンで適切に動作しており、S3 への接続が機能していることになります。
- エージェントを起動すると、Bamboo エージェント ホーム ディレクトリが作成され、Bamboo サーバーから取得されたデータが反映されます。
すべてうまくいけば、エージェントが Bamboo インスタンス リストに表示されます。これで Bamboo エージェントの起動は完了です。
Because the agent has just synchronised itself with the Bamboo server (because it has downloaded all the jars exactly matching what you have on your server), as an extra step, you may want to save that state to speed up future instance startup and reduce bandwidth usage.
そのためには、以下を実行します。
c:\opt\bamboo-elastic-agent\bin\prepareInstanceForSaving.bat
イメージを保存し、新しいイメージ構成を定義し、インスタンスを強制終了して Bamboo から実行してみてください。







4 Comments
Anonymous
Jul 18, 2012The script requires
JAVA_HOMEbut it isn't set by the Java install.Can't the
bamboo-elastic-agent.batuse the registry to find the installed location?Technically it doesn't need
JAVA_HOMEasjavawill be on thePATHso can just be invoked asjavainstead of%JAVA_HOME%\bin\javaMark Snelling
Jan 23, 2013I had to set
BAMBOO_HOME=C:\Users\Bamboo\bamboo-agent-hometo get this to work. The startup script downloaded from the Maven repository expects the user to be Bamboo and this subdirectory to exist.Avner
Aug 21, 2013I've been trying to set up a custom windows image. When I use the scheduled task as defined here, the agent never seems to respond to bamboo server, and remains in 'pending' state. I tried using nssm to run the bat as a service as per this blog and it worked for me.
I'm now trying to change the build working folder, but am struggling to do so. It would be great to get some in-depth documentation of how the agent bootstrapping process works and how to customize it. There is a lot of noise which make it hard to follow the process.
E.g. I noticed this line in the bamboo-elastic-agent.bat file:
cp bamboo-agent-home\bamboo-agent.cfg.template.xml bamboo-agent-home\bamboo-agent.cfg.xml
This appears to be a mistake as cp is not a windows command, and the template file does not exist, so when you run the batch file it comes up with this error. Its probably ignored though.
There is also an environment variable created called %HOME% - Its not clear what uses this down the track, and when I try set it to a different value appears to have no effect on how the agent is run.
To try and change the build folder, I tried changing the buildWorkingDirectory in C:\opt\bamboo-elastic-agent\ebs-resources\bamboo-agent.cfg.xml but was thrown off by a unix path in there. Still I modified this, but the file is apparently not used. When I log into an instance started by bamboo, I can see a different bamboo-agent.cfg.xml file in there. Would be great to know where this comes from.
Avner
Aug 22, 2013Worked it out - should've tried Mark's suggestion first
To change your build folder, set the BAMBOO_HOME environment variable. Here is my modified batch file: