Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,363,173
Community Members
 
Community Events
168
Community Groups

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

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

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

Atlassian Community Events