Navigate back to the homepage

Simple semantic versioning method in Azure DevOps pipelines

Frédéric De Smet
August 28th, 2023 · 1 min read

In essence this is a simple way to use semantic versioning in Azure DevOps pipelines. The idea is to use the build number as the version number. major and minor version are set manually. The patch version is automatically updated on every run.

build.yaml

1...
2variables:
3 major: 0
4 minor: 0
5
6name: $(major).$(minor)$(Rev:.r)
7...

This will result in the following:

Example of above code

The build number can also be retrieved in a release pipeline if you define the build as a resource for the release pipeline. This can be done by using the following code in the build pipeline.

release.yaml

1...
2resources:
3 pipelines:
4 - pipeline: build # Alias used in this run
5 source: example-build # Pipeline name in azure DevOps
6 trigger:
7 branches:
8 include:
9 - main
10...

I would also advice to update the run name of the release with the same build number. This can be done by using the following code in the build pipeline.

1...
2- bash: |
3 echo "##vso[build.updatebuildnumber]$(resources.pipeline.build.runName)"
4...

More articles from blog by Frédéric De Smet

TIP keep your build agent on standby during business hours

Extend the limitations of Azure DevOps.

November 19th, 2021 · 1 min read

Naming convention in Terraform

How can we create a reliable naming convention and centralize the logic behind it.

July 17th, 2021 · 1 min read
© 2020–2024 blog by Frédéric De Smet
Link to $https://twitter.com/dsfrederic_Link to $https://github.com/dsfredericLink to $https://instagram.com/dsfredericLink to $https://www.linkedin.com/in/dsfrederic/