How to update version of maven artifact on Azure pipeline?

Viewed 3198

I am using Azure pipelines (the .yml type) to build and publish an artifact from a Maven project.

Right now all I can do is publish artifacts with the exact version number that is defined in the project's pom.xml file, which is 1.0-SNAPSHOT

I would like the pipeline to automatically remove the -SNAPSHOT from it and update the patch version every time a new artifact is built and released, increasing the patch version based on the latest release. so it would be 1.0.1, then 1.0.2 after that, and so forth.

What should I change in the pom.xml or in the azure-pipelines.yml to make that happen?

1 Answers

You can replace the content of <version> by ${revision}, add <revision>1.0-SNAPSHOT<revision> to the <properties> section of the POM.

Then you can override the value by adding -Drevision=1.0.1 on the command line.

Of course, to make this smooth, you need to write logic in your pipeline to read the original version and set the new version depending on this.

You can also try the following plugin

https://danielflower.github.io/multi-module-maven-release-plugin/

but I don't know if it works or not.

Related