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: 04 minor: 056name: $(major).$(minor)$(Rev:.r)7...
This will result in the following:
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 run5 source: example-build # Pipeline name in azure DevOps6 trigger:7 branches:8 include:9 - main10...
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...