How do I include the Bamboo build number in my plugin's version string?

Andrew Ardill
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.
May 29, 2011

I would like to include the bamboo build number in my plugin's version string. What is the best way of doing this?

I would like my version to read, for example, v1.0.0#12, where this is version 1.0.0 and sequential build 12.

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Andrew Ardill
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.
May 30, 2011
Jens' answer was very useful, I am going to add the solution I used here for completeness sake. This code is more or less completely copied from the documentation linked by Jens however there are some inconsistencies that mean the code there does not work as is, and can cause issues!
The documentation says to use ${env.bambooBuildNumber} however you really want
${bambooBuildNumber}

First I added an environment variable 'bambooBuildNumber' to my plugin's pom.xml, in the <version> element. This was decided to cause too many issues, so we moved it to the atlassian-plugin.xml <description>
<plugin-info>
<description>${project.description} Build ${bambooBuildNumber}</description>
This will allow us to view the build number quickly and easily, but won't affect any dependancies. Notice that the build variable does not have 'env.' prefixed to the start of it.
I then modified the maven goal in my bamboo build to set the environment variable:
clean package -DbambooBuildNumber=${bamboo.buildNumber}
This is working swimmingly for us now.
Tom Towkach
Contributor
August 13, 2012

I create JAC https://jira.atlassian.com/browse/BAM-12042 . You may want to vote on this to bring more visability to development.

4 votes
Jens Schumacher [Atlassian]
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.
May 29, 2011

Bamboo provides a number of pre-defined system variables that you can use in your build configuration. You can find all available variables in the documentation under:

http://confluence.atlassian.com/display/BAMBOO/Using+Global%2C+Plan+or+Build-specific+Variables

To get the build number, you can simply use the following variable: {$bamboo.buildNumber}

To get the version, you would simply specify a Plan variable and use it along the build variable above.

Michal Ziv
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!
June 10, 2015

this does not work in maven!

TAGS
AUG Leaders

Atlassian Community Events