Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting new Docker container with every new Bamboo build run and using the container to run the build in

Tags:

docker

bamboo

I am new to Bamboo and are trying to get the following process flow using Bamboo and Docker:

  1. Developer commits code to a Bitbucket branch
  2. Build plan detects the change
  3. Build plan then starts a Docker container on a dedicated AWS instance where Docker is installed. In the Docker container a remote agent is started as well. I use the atlassian/bamboo-java-agent:latest docker container.
  4. Remote agent registers with Bamboo
  5. The rest of the build plan runs in the container
  6. Container and agent gets removed when plan completes

I setup a test build plan and in the plan My first task is to start a Docker instance like follows:

sudo docker run -d --name "${bamboo.buildKey}_${bamboo.buildNumber}" \
   -e HOME=/root/ -e BAMBOO_SERVER=http://x.x.x.x:8085/ \
   -i -t atlassian/bamboo-java-agent:latest

The second task is to get the source code and deploy. 3rd task is test and 4th task is shutting down the container.

There are other agents online on Bamboo as well and my build plan sometimes uses those and not the Docker container that I started as part of the build plan.

Is there a way for me to do the above?

I hope it all makes sense. I am truly new to this and any help will be appreciated.

like image 329
Jacobus van heerden Avatar asked Jan 22 '15 12:01

Jacobus van heerden


1 Answers

We (Atlassian Build Engineering) have created a set of plugins to run Docker based agents in a cluster (ECS) that comes online, builds a single job and then exits. We've recently open sourced the solution.

See https://bitbucket.org/atlassian/per-build-container for more details.

like image 109
mkleint Avatar answered Oct 06 '22 22:10

mkleint