0

This is a follow up of this question

I'd like to put the number of my build in the description (and in other tasks), when using BuildId it works without any problem.

But if I use $(rev:.r), this variable is not interpreted and I have an error saying that the number version is not correct (invalid characters such as $ and :).

Here's some code working with BuildId but not with Rev :

variables:
- group: NumVersion
- name: upperversion
  ${{ if eq(parameters.VersionBuild,'ReleaseProd') }}:
    value: $(1-VersionMajeur).$(2-VersionMineure-ReleaseProd)
  ${{ if eq(parameters.VersionBuild,'Release') }}:
    value: $(1-VersionMajeur).$(2-VersionMineure-Release)
  ${{ if eq(parameters.VersionBuild,'Develop') }}:
    value: $(1-VersionMajeur).$(2-VersionMineure-Dev)

- name: lowerversion
  ${{ if eq(parameters.TypeBuild,'Feature') }}:
    value: 99.$(Build.BuildId)
  ${{ if eq(parameters.TypeBuild,'Production') }}:
    value: $(3-VersionCorrective-Release).$(rev:.r)

name: $(upperversion).$(lowerversion)

stages:
- stage: Build
  jobs:
  - job: Prerequisites
    displayName: Prerequisites
    steps:
    - checkout: self
    - script: |
       echo '##vso[build.updatebuildnumber]$(upperversion).$(lowerversion)

Did somebody encounter this? Thanks in advance!

Goufalite
  • 2,253
  • 3
  • 17
  • 29

1 Answers1

1

According to the docs you can’t use this variable other than in the build number / name field.

In Azure DevOps $(Rev:r) is a special variable format that only works in the build number field. When a build is completed, if nothing else in the build number has changed, the Rev integer value increases by one.

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/run-number?view=azure-devops

promicro
  • 1,280
  • 7
  • 14