Bamboo 4.2 : Creating a custom elastic image - Windows

To perform the tasks listed below, log in to your instance with an Administrator account using Remote Desktop Client.

Subscribing to this page is the best idea you're going to have today.

Setting up the user account

Create the user account that will be used by the Bamboo agent. The account name is up to you, I will use Bamboo in the examples below. All builds running on your machine will use this account. It can be a regular user (i.e. it does not need to be a Power User or Administrator, unless your builds require it). Set up a password for that user. The default user on a Windows image has a user name of Bamboo with a password of Atlassian1.

Important: by default, a newly created user should be denied remote login rights (which is as we want it to be). To be on the safe side, please make sure that you indeed cannot log in using that user's credentials (unless you change them to non-default ones

If your builds are not headless (i.e. they show/manipulate windows, like Selenium does), click here for additional instructions

You'll need to set up autologin for your Bamboo account (don’t worry, this will not let remote users in). To do this, run control userpasswords2 and uncheck “User must enter a user name and password to enter this computer”:


 

Setting up the firewall

Reconfigure the Windows firewall to accept TCP connections on port 26224. No other inbound connections are necessary for Bamboo.

You don’t need to worry about changing the EC2 security group setting for this port, Bamboo will set it up automatically:

Installing the required software

  1. Install a supported Oracle Java version (6 or 7).
  2. 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-agent to match stock images distributed with Bamboo.
  3. 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 task with Action “Start a program->PATH TO YOUR BATCH FILE”. Remember to select “Run whether user is logged on or not” in the “General” tab and appropriately define the task Trigger so that the agent starts up only after the network connection is up and running.

The task manager will warn you that the account needs to be able to log in as a batch job. Make sure the “Log on as batch job” policy is set for the user. This policy is accessible by opening the Control Panel -> Administrative Tools -> Local Security Policy. In the Local Security Policy window, click Local Policies -> User Rights Assignment -> Log on as batch job:

Testing

The easiest way to check if everything is set up correctly, is to run the task you've defined using Windows Task Scheduler (Start->Administrative Tools->Task Scheduler). Right click on the task and select "Run". Always test the script using the Task Scheduler - if you run the script manually, you'll use Administrator account, which is not what we want.

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.

Run c:\opt\bamboo-elastic-agent\bin\prepareInstanceForSaving.bat .Bundle your instance. Make note of the AMI id of the new image.

Start your image from Bamboo

If you fail to complete the following steps within ~40 minutes, Bamboo will shut down your instance, so remember to save your work if you’re running out of time (i.e. create an interim image).

In Bamboo, define an image configuration for the image you've just created, and start it from Bamboo. If everything went well, the agent will start together with the instance. It will perform the following steps:

  • Update/create /opt/bamboo-elastic-agent directory structure by creating additional directories . If they appeared, Java is working correctly on that machine and the connection to S3 is working.
  • Start the agent which will create the Bamboo Agent Home directory and populate it with data pulled from Bamboo server.

If everything went well, you should see the agent appear in the Bamboo instance list. Congratulations, you have a working Bamboo agent.

Because the agent has just synchronised itself with the Bamboo server you have (i.e. 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.

To do it, run c:\opt\bamboo-elastic-agent\bin\prepareInstanceForSaving.bat , save the image, define a new image confguration, kill the instance, and try running it from Bamboo.

Attachments:

nopwdlogin.png (image/png)
firewall.png (image/png)
batchjob.png (image/png)
task-definition.png (image/png)