In my yaml file I defined some variables which should contain the value of the month ($MinorVersion)
or year ($MajorVersion)
, by setting the value to '$(Month)'
and/or '$(Year:yy)'
. When I print them in the task script or task powershell it only displays '$(Month)'
and/or '$(Year:yy)'
. The expected output of the variable $(MajorVersion)
is of course the current month and year 09
and 20
.
Can someone tell me how I can access the variable $MinorVersion
in the task script / powershell to get the actual value of it? That's the files content:
trigger:
- master
pool:
vmImage: 'windows-latest'
#import variable group resize-group, local variables are name/value pairs
variables:
- group: resize-group
- name: buildConfiguration
value: 'Release'
- name: appxPackageDir
value: '$(build.artifactStagingDirectory)\AppxPackages\\'
- name: MajorVersion
value: '$(Year:yy)'
- name: MinorVersion
value: '$(Month)'
- name: PatchVersion
value: 45
- name: RevVersion
value: '$(BuildID)'
- name: Packageappxmanifest
value: Package.appxmanifest
- name: PackageVersion
value: '$(MajorVersion).$(MinorVersion).$(PatchVersion).$(RevVersion)'
name: $(BuildDefinitionName)_$(MajorVersion).$(MinorVersion).$(PatchVersion)$(RevVersion)
steps:
- checkout: self
submodules: true
- script: |
echo %MinorVersion%
echo %variables.MinorVersion%
echo $($[variables.MinorVersion])
echo ${{ variables.MinorVersion }} # outputs initialValue
echo $(Month)
echo $(MajorVersion)
echo $(MinorVersion)
echo $(RevVersion)
echo $(PackageVersion)
echo $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
- powershell: |
Write-Host $env:MinorVersion
Write-Host $env:variables.MinorVersion%
Write-Host "$env:MY_MAPPED_PACKAGEVERSION"
Write-Host "$env:MY_MAPPED_REVVERSION"
Output only displays the unevaluated content of the variables: