Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bamboo Docker Tag Best Practice

Curtis
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 16, 2017

Hi,

I want to use Bamboo to start doing the building of  Docker images. But I would like a better tag than just giving everything the "latest". And I don't want to have to go back in and tag each. The Dockerfile will have a version of the application it is building in many cases.

What is the best methods found for a good version naming scheme when doing builds in Bamboo? Most of the images I currently am building, are based on applications that have their own versions, so I have been using those as the tag for the version, then an added increment number if I have rebuilt, but not updated the applications version. This increment I plan to use the Bamboo build number instead.

What is everyone else commonly doing?

Thanks,
Curtis

2 answers

1 accepted

0 votes
Answer accepted
Curtis
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 26, 2018

I did as @Michel Vallée suggested. I created a inline script task to extract from the Dockerfile any and all variables I needed, setting them as Bamboo Variables through the InjectedVariablesTask. Then, use that variable in all places necessary, the primary one being in naming the new image, which is exactly as @Michel Vallée suggested:

my-registry/my-app-image:${bamboo.inject.VERSION}-${bamboo.buildNumber}

Here is an example of the inline script used to get the variable value from the Dockerfile:

grep "HTTPD_VERSION" Dockerfile | cut -d' ' -f 2 > properties.txt

This command saves  the value to a file named "properties.txt". The next step is then the "Inject Bamboo Variables" in which you provide it the "properties.txt" file as the properties file.

Then, anywhere you want to use the variable retrieved from the Dockerfile, you would do:

${bamboo.inject.HTTPD_VERSION}

 If you want this variable to be available to another job in a later stage or release, just select "Result" in the "Inject Bamboo Variable" task.

Jlk
Contributor
October 7, 2020

I just signed up yesterday so I'm curious as to how I can get all of the products that are compatible. How many are available exactly? I haven't even seen Bamboo yet!

Curtis
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 15, 2020

We use Jira, Confluence, Bitbucket and Bamboo. They all work together and easily integrate to help give context in each of them. With Bamboo, we can easily see with each build, who executed it and what changes/commits existed new to that build from the previous build.

Like Jlk likes this
0 votes
Michel Vallée
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 28, 2017

Having same problem.  Want the version to be in the Dockerfile but also part of the tag.

Not sure how to have Bamboo retrieve the version from the Dockerfile and use it as part of a variable.

I was able to run a script to export it to a file then use the InjectVariablesTask to retrieve back out.  However, my understanding is that the variable is then only available on the agent or in deployment plans.  It is NOT available in a follow-up task in the same plan.

I.e. I need in the step right after where I use the DockerBuildImageTask which is where I want to specify the tag to use.

I want to use the format:

my-registry/my-app-image:${bamboo.inject.VERSION}-${bamboo.buildNumber}

Curtis
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 1, 2017

If you set the scope for the InjectVariablesTask to not local, it will make it available in other jobs in later Stages in the same Plan.

Michel Vallée
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 1, 2017

I'll split my stage in two to see if that helps.  Thanks!

Curtis
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 26, 2018

Just out of curiosity, did you get your desired setup working? Were you able to pass the variable to the second stage?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events