Azure DevOps: релизная версия - PullRequest
0 голосов
/ 13 июля 2020

Я собираюсь создать свой конвейер CI / CD в Azure DevOps, но у меня проблема с номером версии выпуска. с этим CI / CD создана сборка приложения do tnet и образ docker, поэтому я хочу, чтобы номер выпуска образа docker был таким же, как: V1.2.0 и ..... но в настоящее время у меня есть номер, например : 10, 11, ... или только последний тег! Может ли кто-нибудь помочь мне получить собственный номер версии выпуска? Спасибо

Ответы [ 2 ]

0 голосов
/ 14 июля 2020

Вы можете установить номер версии выпуска в Конвейеры выпуска -> Параметры -> Общие -> Формат имени выпуска .

enter image description here

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

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

Result:

enter image description here

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(e.g. BuildRevision :$[counter( ' ',0)]).

enter image description here

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

enter image description here

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

enter image description here

Result:

enter image description here

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.

введите описание изображения здесь

0 голосов
/ 13 июля 2020

В этом случае вы можете использовать GitVersion и Semanti c Шаблон управления версиями. Для этого вам понадобится это расширение: https://marketplace.visualstudio.com/items?itemName=gittools.gitversion

После этого вы добавляете шаг перед компиляцией / сборкой вашего проекта:

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

После этого вы можете использовать переменная:

$ (GitVersion.FullSemVer)

Эта переменная будет хранить текущую версию сборки - она ​​основана на git.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...