如何使用参数在Azure DevOps中使用或任务条件
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')
任一代理匹配,则条件应允许执行任务。
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) )
Added the complete code. Default value will be test111. Just need to verify the condition and execute the tasks.
Note: If i use only one condition then its working like below.
eq('$ {{parameters.agents}}', 'test111')
Either of any one agent is matched, then condition should be allow to execute tasks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这种方法应该起作用。由于在编译时间之前填充了参数,因此您应该将此值分配给一个变量,以便在条件步骤上使用它。
由于在条件下正确评估默认值,
powershell
将运行。This approach should work. As parameters are populated before the compile time, you should assign this value into a variable in order to use it on the condition step.
As the default value is evaluated correctly on the condition, the
powershell
will run.