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

Automatically update version in pom.xml when Bitbucket merges a branch into master

Samuel VanFossen May 4, 2021

I'm new to Bitbucket and Bamboo, and I'm looking for a way to make sure that whenever someone successfully merges from another branch to the master branch, the version listed in the pom.xml is updated. For example:

1.24-SNAPSHOT => 1.25-SNAPSHOT

I'd appreciate any input you might have, and I apologize if this information is vague!

1 answer

1 vote
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 12, 2021

Hi @Samuel VanFossen, welcome to Atlassian Community!

To set the version number as dynamic value, you'll need to declare the equivalent Bamboo variable bamboo.buildNumber during the execution of the Maven script.

For example, you may want your Maven 2 version to be determined by Bamboo. In Maven 2 pom.xml you may have:

...
<groupId>com.atlassian.boo</groupId>
<artifactId>boo-test</artifactId>
<packaging>jar</packaging>
<version>1.1.${bambooBuildNumber}-SNAPSHOT</version>
...

You can then specify the following in the Goal field of your build plan:

clean package -DbambooBuildNumber=${bamboo.buildNumber}

When the command runs, Bamboo will replace bamboobuildNumber with the actual number (e.g. 1102), which will be passed to the underlying Maven build to use. The command will then produce a jar that looks like this: boo-test-1.1.1102-SNAPSHOT.jar.

More information can be found here.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events