我正在努力完成这个简单的任务:
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}
Run Code Online (Sandbox Code Playgroud)
如何在 azure 管道中打印变量以输出的正确方法是什么?
关于如何使用自定义变量,请查看 doc Set variables in pipeline。
在您的情况下,当您想使用该变量时,它应该$(myVariable)代替${myVariable}.
请参考以下演示:
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)'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2563 次 |
| 最近记录: |