Versioning using Azure DevOps pipeline

Chintan Doshi
2 min readFeb 27, 2021

Nowadays many companies are using Azure Devops for CICD. I also recently migrated jenkins pipeline to azure devops pipeline and one of the major difference I saw was regarding versioning for maven based applications (mainly spring-boot or if you have old spring mvc based). There are 2 versioning we need to care about in AzDO pipeline.

  1. Version of the build pipeline it self : By default AzDO will generate unique number for every build based on timestamp but are you fine with this versioning or you need some custom text/identifiers in that version? If you want customisation, then it is possible using below command :
steps:
- bash: |
echo "##vso[build.updatebuildnumber]$(major).$(minor).$(patch)"

2. Version of your pom and release artifact : Here it’s bit tricky. Till now I was used to create release version using maven-releases plugin which will update your pom with release version, deploy artifact in your artifactory as released version and will also update pom to next incremental snapshot version for next development iteration. I was very comfortable with this approach (even though sometimes, if you create hotfix release or run maven-release locally and it may give some trouble but still overall it was smooth).

In Azure devops pipeline also I could have used same release strategy but there was 1 main issue : My pipeline was creating release and as part of maven release steps, it will try to commit updated pom in project repo. My AzDO repo policies were set to “Allow merge to master branch only via PR” and unfortunately I could not exclude build user (like it is allowed in bitbucket). Then I started thinking about, do we really need to use maven-release? If my artifact is not going to be used by any other department or third party, why do we care about version? In this care, I just want to make sure that at any given point of time:

A) I should be able to see which version (or artifact, because versioning we don’t care :P ) is deployed in production. This can be achieved easily if you also use AzDO release pipeline.

B) If I have to do hotfix on deployed version then how can I checkout exact same code which is running in production? This I achieved by just tagging with my build number in AzDO Repo. So during hotfix, I can just checkout tagged version.

But now, question is still open : How shall we achieve versioning for libraries which is actually going to be used by other departments? Please let me know your thinking in the comment !

Azure devops pipeline logo
image credit : https://slack.com/apps/AFH4Y66N9-azure-pipelines

--

--