parameters:
- name: agents
displayName: Agent
type: string
default: test111
- name: tests
displayName: “Hello test”
type: string
default:
'"Hello World"'
- name: configuration_key
displayName: Special Parameter Keyword
type: string
default: ""
jobs:
- job: tesst1
strategy:
matrix: ${{ parameters.execution_matrix }}
variables:
- name: 'TEST_S'
value: ${{ parameters.tests }}
- name: 'configuration_key'
value: ${{ parameters.configuration_key }}
displayName: App test
timeoutInMinutes: 600
pool:
name: System_test
- task: DownloadPipelineArtifact@2
inputs:
source: 'specific'
project: ‘Test APP’
buildType: 'current'
artifactName: ‘App Installer'
pipeline: 001
runVersion: 'latestFromBranch'
runBranch: 'refs/heads/develop'
targetPath: '$(Build.SourcesDirectory)/'
displayName: 'Get Artifacts'
condition: or( eq(‘{{parameters.agents}}', ‘test111’), eq(‘{{parameters.agents}}’, ‘test’222) )
添加了完整的代码。默认值为 test111。只需验证条件并执行任务即可。
Note: If i use only one condition then its working like below.
eq('$ {{parameters.agents}}', 'test111')
任何一个代理匹配,则条件应允许执行任务。
最佳答案
这种方法应该有效。由于参数是在编译之前填充的,因此您应该将此值分配给变量,以便在条件步骤中使用它。
trigger:
- none
pr: none
parameters:
- name: image
displayName: Pool Image
type: string
default: ubuntu-latest
values:
- windows-latest
- ubuntu-latest
- macOS-latest
pool:
vmImage: ubuntu-latest
variables:
- name: myvar
value: ${{ parameters.image}}
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
# Write your PowerShell commands here.
Write-Host "Hello World"
condition: or( eq(variables.myvar, 'ubuntu-latest'), eq(variables.myvar, 'windows-latest') )
由于根据条件正确评估了默认值,powershell
将运行。
关于azure - 如何使用参数在azure devops中使用OR任务条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71676544/