azure-devops - 默认取消选择阶段

标签 azure-devops yaml

在 Azure Devops 多级 YAML 管道中,我们有多个环境。
在正常运行的阶段,我们只在 QA 中进行构建和部署,因此我们需要手动取消选择每个阶段。默认情况下,所有阶段都被选中是否有可能完全相反,默认情况下所有阶段都被取消选择???
select stages

trigger: none
pr: none
stages:
- stage: 'Build'
  jobs:
  - deployment: 'Build'
    pool:
      name: Default
# testing
    environment: INT
    strategy:
      runOnce:
        deploy:
          steps:
          - checkout: none
          - powershell: |
              echo "Hello Testing"
              Start-Sleep -Seconds 10
- stage: 'Sandbox'
  jobs:
  - job: 'Sandbox'
    pool:
      name: Default
    steps:
    - checkout: none
# testing
    - powershell: |
        echo "Hello Testing"
- stage: 'Test'
  jobs:
  - job: 'DEV'
    pool:
      name: Default
    steps:
    - checkout: none
    - powershell: |
        echo "Hello Testing"
- stage: 'QA'
  dependsOn: ['Test','Test1','Test2']
  jobs:
  - job: 'QA'
    pool:
      name: Default
    steps:
    - checkout: none
      # Testing
    - powershell: |
        echo "Hello Testing"

最佳答案

恐怕没有可以满足您需求的 UI(如 stage to run)方法。
您可以尝试将参数添加到您的 Yaml 示例中。
下面是一个例子:

trigger: none
pr: none

parameters:
- name: stageTest
  displayName: Run Stage test
  type: boolean
  default: false
- name: stageBuild
  displayName: Run Stage build
  type: boolean
  default: false

stages:
- ${{ if eq(parameters.stageBuild, true) }}: 
  - stage: 'Build'
    jobs:
    - deployment: 'Build'
      pool:
        name: Default
      environment: INT
      strategy:
        runOnce:
          deploy:
            steps:
            - checkout: none
            - powershell: |
                echo "Hello Testing"
                Start-Sleep -Seconds 10

- ${{ if eq(parameters.stageTest, true) }}: 
  - stage: Test
    dependsOn: []
    jobs:
    - job: B1
      steps:
      - script: echo "B1"
这些参数用于确定是否运行这些阶段。您可以在 stage 之前添加表达式以检查参数值是否满足表达式。
默认值为假。这意味着该阶段默认不会运行。
结果如下:
enter image description here
您可以通过单击选择框来选择您需要运行的阶段。
更新
解决方法有一些 限制 . When the select stage has depenencies, you need to select all dependent stages to run.
例如:
  - stage: 'QA'
    dependsOn: ['Test','Test1','Test2']
enter image description here
另一方面,我创建了一个建议票来报告此功能请求。这是建议票链接:Pipeline Deselect Stages By Default您可以投票并在其中添加评论。

关于azure-devops - 默认取消选择阶段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63491707/

相关文章:

c# - MVC 5 构建在 Visual Studio Team Services 上失败

ruby-on-rails - Rails I18n 多文件别名

tagging - 了解 Gitlab CI 标签

在阶段之间传播期间第二次访问时,Azure Pipeline 变量值会丢失

azure - 我们可以在一个 yaml 文件中使用多个触发器来执行不同的作业吗?

ruby - 为什么 YAML 将 '0777' 解释为 511?

java - 如何将变量从 yaml 文件读取到 application.properties 中?

azure - 如何使用yml文件为azure管道中的不同分支设置不同的参数

c# - 如何检测何时可以安全升级我的 Windows 服务?

azure - 为 SourceVersion 指定的值不是有效的提交 ID