It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Automate the version assignment with Maven release:prepare in Bamboo


I am working on automating the maven release process in a Bamboo plan.

In a Maven task I have the following release:prepare command using both global and plan variables:

release:prepare --batch-mode -Dusername=${bamboo.custom.svn.username} -Dpassword=${bamboo.scmPassword} -DdevelopmentVersion=${bamboo.snapshotVersion} -DreleaseVersion=${bamboo.releaseVersion}

Both variables ${bamboo.snapshotVersion} and ${bamboo.releaseVersion} are defined at plan level.

Actually, the intent behind setting the maven parmateres "developmentVersion" and "releaseVersion" is to pass a customized version number. But by this way, the users must each time run a customized build and passes the correct parameter values.

Now I need to configure my Bamboo plan, to achieve both use cases in one plan:

1- Pressing "run build" without passing the values for the version variables just leaves the maven release plugin to determine the next development version.

2- Using "run customized build" and overriding both variables will produce the given version numbers for release and snapshot.

While searching I found these 2 interesting plugins:

The first (beta) plugin "bamboo-maven-version-update-plugin" offers the possibility to auto-increment the version values in both variables, in case they might be forgotten. But it can't sync the snapshotVersion variable with the POM’s version to make sure they’re the same value.

While the second one "Maven POM Value Extractor" can keep the plan variable ${bamboo.snapshotVersion} in sync with the POM element "<version>" before performing release:prepare. But the value for ${bamboo.releaseVersion} in turn will still have to be set manually.

I thought I could define 2 tasks by using both plugins before performing the release:prepare task to:

1. Keep the plan variable ${bamboo.snapshotVersion} in sync with <version> element in POM.

2. Auto-increment the ${bamboo.snapshotVersion} variable if not given explicitly by the user.

But I didn't find a way to "auto determine" the ${bamboo.releaseVersion} value if not given.

Is it even possible to achieve this?



3 answers


Similar situtation, where I would like to increment plan variables. Deployment plans are great, but when you need the release version (and the next release/development version) for the build plan itself they are useless.



I retrieve the major minor revision number from a .properties file in order to validate that it is correct. I use a small regex script to do the parsing. Something like:

FINDSTR /X /I /C:"version=R${bamboo.current.version}" ${}\Build\

(modify for whatever string you have in your pom file, in my example above I'm matching what is in the file against a user entered variable ${bamboo.current.version} to validate that the developers remembered to update the version number which is done manually in the source. You would not be matching but parsing for some pattern like: version= \d+.\d+.\d+ and isolating the part you wanted for your variable then assigning that to whatever gets written to the txt file.)

Just kicking it around, I'd write the results of that query to a txt file, inject it using the injection variable. You could add some math to the number by breaking it up into it's parts, incrementing what needed incrementing and appending the parts back together again before writing it.

No question, it's a clumsy implementation but it can be done. There's probably some really smart guy out there who could give you a much more elegant solution, if he's paying attention. I think the hardest thing about using bamboo is figuring out what bamboo can do and what you have to do yourself so that you can pass it to bamboo.

I have the exact same use case as described here, anyone have any further ideas??

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bamboo

Cannot save a repository using Chrome v83

Hello Bamboo Community, I'm Jey from Bamboo Support team. If you have upgraded your Chrome browser to version 83 recently, it is observed that the save operation just spins and never completes w...

143 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you