我认为我从powershell步骤中调用变量os_name是错误的;每次我测试构建时,它都不会通过if语句。我在想我的密码怎么了。是否有人尝试过在azure表达式中使用类似于此的运行时变量?
- powershell: |
$os_name = 'linux'
echo "##vso[task.setvariable variable=os_name;]$os_name"
- ${{ if eq( variables.os_name , 'linux') }}:
- powershell: |
echo "variables.os_name = linux"发布于 2022-06-02 11:15:03
这应该适用于你:
- task: PowerShell@2
displayName: set variable
inputs:
targetType: 'inline'
script: |
"##vso[task.setvariable variable=os_name;]linux"
- task: PowerShell@2
displayName: Linux case
inputs:
targetType: 'inline'
script: |
Write-Host "Linux"
condition: eq(variables.os_name, 'linux')运行Linux:

为非Linux运行:

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