'Azure pipeline uses expression and not value
I use the following azure pipeline (it is simplified for testing):
parameters:
  - name: BUILD_QUALITY
    displayName: What is the build quality?
    type: string
    default: "alpha"
    values:
      - alpha
      - beta
      - preview
      - release
trigger: none
variables:
  solution: "**/*.sln"
  buildPlatform: 'Any CPU'
  buildConfiguration: "Release"
  patch: $[counter(variables['CustomVersion'], 1)]
  versionNumber: $(Year:yyyy).$(Month).$(DayOfMonth)
  ${{ if eq( parameters['BUILD_QUALITY'], 'release') }}:
    VERSION_NUMBER: ${{ variables.versionNumber }}.$(patch)
  ${{ else }}:
    VERSION_NUMBER: ${{ variables.versionNumber }}.$(patch)-${{parameters['BUILD_QUALITY']}}
name: Test_${{ variables.versionNumber }}.$(patch)
pool:
  vmImage: "windows-latest"
stages:
  - stage: buildCliTool
    jobs:
      - job: cliTool
        steps:
          - script: echo "versionNumber is ${{ variables.versionNumber }}"
          - script: echo "Build name is $(Build.BuildNumber)"
          
  - stage: buildNuget
    jobs:
      - job: nuget
        steps:
          - script: echo "versionNumber is $(versionNumber)"
          - script: echo "versionNumber is $(VERSION_NUMBER)"
  
Script steps are used to check, whether variables values are correct.
But, they print correct value just for expression - script: echo "Build name is $(Build.BuildNumber)"
In all other cases, output is not value, but expression itself.
I'd like to use versionNumber in my stages, but now it does not have proper value.
Could someone suggest please, how should I use that variable to obtain value, and not expression body?
Solution 1:[1]
The problem is with the tokens you're using in this variable:
versionNumber: $(Year:yyyy).$(Month).$(DayOfMonth)
Those year, month and dayofmonth tokens – you can't use them in normal variables, only when defining a build number:
You can use these tokens only to define a run number; they don't work anywhere else in your pipeline.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | Vince Bowdren | 


