0

I'm trying to change a build description text according to some parameters. The BuildNumber follows but the build description (the big name of the build) doesn't seem to interpret the variables.

Here's an extract of the yaml

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,'Validation') }}:
    value: 0.$(Build.BuildId)

name: $(upperversion).$(lowerversion)

steps:
  - script: |
       echo $(Build.BuildNumber)
       echo $(upperversion)
       echo $(lowerversion)
    displayName: Second variable pass

The output of the bash script

buildnumber is correctly set with the $(1-...) interpreted

The name of the build

the name of the build just copies the $ as uninterpreted

Did I forget something to set or should I use another way of calling the variables?

Thanks for your help!

Goufalite
  • 2,253
  • 3
  • 17
  • 29

1 Answers1

1

The Buildnumber is set when the job is initialized, not in the order in which it's specified in the YAML file.

To fix your issue you must run one step to set the buildnumber as part of your workflow. You can do this in a separate job, or as part of the very first joḃ.

- script: |
       echo ##vso[build.updatebuildnumber]$(upperversion).$(lowerversion)

Or use my Azure Pipelines Variables tasks:

- task: VariableSetTask@2
  inputs:
    variableName: 'build.buildnumber'
    value: '$(upperversion).$(lowerversion)'
jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • I had to not use quotes in your first script ( `echo '##vso[build.updatebuildnumber]$(upperversion).$(lowerversion)` ). The title shows correctly at the end of the pipeline so it works. Thanks! – Goufalite Oct 27 '22 at 16:20