Azure DevOps Server多阶段流水线:重新运行阶段支持运行时参数输入?
可以实现,以下是两种可行方案
方案1:使用流水线运行时参数
直接在YAML流水线中声明运行时参数,重新运行阶段时可在触发界面直接修改参数值,无需切换到变量组窗口。
示例YAML配置:
parameters: - name: targetEnvironment type: string default: 'dev' values: - dev - test - staging - name: testTimeoutSeconds type: number default: 300 min: 60 max: 1800 stages: - stage: Deploy jobs: - job: DeployToEnv steps: - script: echo Deploying to ${{ parameters.targetEnvironment }} - stage: IntegrationTest jobs: - job: RunTests steps: - script: echo Running tests with timeout ${{ parameters.testTimeoutSeconds }}s
- 触发重新运行时,在弹窗的「参数」标签页即可直接编辑这些值。
- 要求Azure DevOps Server 2020及以上版本支持该特性。
方案2:阶段级可编辑变量
针对特定阶段配置允许运行时编辑的变量,重新运行该阶段时可直接在运行配置界面修改变量值。
示例YAML配置:
stages: - stage: IntegrationTest variables: - name: testSuiteName value: 'FullRegression' readonly: false # 允许运行时修改 - name: retryCount value: '2' readonly: false jobs: - job: ExecuteTests steps: - script: echo Running test suite $(testSuiteName), retry $(retryCount) times
- 重新运行该阶段时,在弹窗的「变量」标签页找到对应阶段的变量,直接修改即可生效。
注意事项
- 两种方式都无需跳转至变量组管理窗口,所有参数/变量修改操作都在重新运行的触发界面完成。
- 若使用的是Azure DevOps Server旧版本(低于2020),需先升级服务器以支持运行时参数特性。
内容的提问来源于stack exchange,提问作者Vowneee
相关产品推荐
相关产品推荐

