Automate the version assignment with Maven release:prepare in Bamboo

Hi,

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?

Regards,

Wahid

3 answers

This widget could not be displayed.

+1

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.

Cheers,

Gary

This widget could not be displayed.

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}" ${bamboo.build.working.directory}\Build\release.properties

(modify for whatever string you have in your pom file, in my example above I'm matching what is in the release.properties 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.

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published yesterday in Marketplace Apps

The 7 hacks of highly successful automation

...there's anything I've learnt from working, it's that people are lazy! No offense to anyone reading this, but it's true and we can all admit it. The easier you make something for someone, the more...

94 views 0 8
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you