简体   繁体   中英

Azure DevOps: release version

I am going to create my CI/CD pipeline in Azure DevOps, but I have a problem with release version number. with this CI/CD a dotnet app build and a docker image created, so I want to have docker image release number same as: V1.2.0 and..... but currently I have number for example: 10, 11, ... or only the latest tag? Can anybody support me to have my own release version number ? Thanks

You could set the release version number in Release Pipelines -> Options -> General -> Release name format .

在此处输入图像描述

The $(rev:r) is an incrementing variable. So you could add it in the Release version.

For example: V1.2.$(rev:r)

Result:

在此处输入图像描述

Note: the $(rev:r) counts from 1 (1,2,3...).

From your requirement, you are using CI and CD process and it seems that you need to count from 0. You also could try to use the $(Build.buildnumber) variable.

Here are the steps:

Step1: In Build Pipeline(CI), set the count variable(eg BuildRevision:$[counter( ' ',0)] ).

在此处输入图像描述

Step2: Use the variable in Build number (Build Pipeline->Options ->Build number format).

在此处输入图像描述

Step3: Set the build artifacts as the release source. Use the $(Build.buildnumber) in release pipeline version.

在此处输入图像描述

Result:

在此处输入图像描述

In this situation, the release version could start from v1.2.0.

Update:

when I change the release version for example from V0.0 to V1.0, how the counter restarted?

You could try the following steps:

Create 2 variables:

1. major-minor = 0.0

2. revision = $[ counter(variables['major-minor'],0) ]

The build number: $(major-minor).$(revision)

In this case, when the major-minor change as V1.0, the counter will reset.

在此处输入图像描述

In that case you can use GitVersion and Semantic Versioning pattern. For that you will need this extension: https://marketplace.visualstudio.com/items?itemName=gittools.gitversion

After that you add the step before compiling/build your project:

steps:
 - task: GitVersion@5
   inputs:
      runtime: 'core'

After that you can use variable:

$(GitVersion.FullSemVer)

That variable will store the current build version - it's based on git.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM