我正在努力完成这个简单的任务:
variables:
myVariable: 'ValueFromVar'
- task: PowerShell@2
inputs:
targetType: 'inline'
script: ${myVariable} # prints empty
- task: PowerShell@2
displayName: Display version of app
inputs:
targetType: 'inline'
script: 'Write-Host "Version of app: ${myVariable}"' # prints empty
- task: Bash@3
inputs:
targetType: 'inline'
script: echo '${myVariable}' # prints ${myVariable} 在azure管道中输出变量的正确方式是什么?
发布于 2020-02-06 16:10:11
关于如何使用自定义变量,请查看文档集variables in pipeline。
在您的例子中,当您想要使用该变量时,它应该是$(myVariable)而不是${myVariable}。
请参考下面的demo:
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
myVariable: 'ValueFromVar'
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: '"$(myVariable)"'
- task: PowerShell@2
displayName: Display version of app
inputs:
targetType: 'inline'
script: 'Write-Host "Version of app: $(myVariable)"'
- task: Bash@3
inputs:
targetType: 'inline'
script: echo '$(myVariable)'

https://stackoverflow.com/questions/60074591
复制相似问题