Deselect Stages By Default

Viewed 2017

In Azure Devops multistage YAML pipeline we got multiple environments. In stages to run normally we do a build and deploy only in QA, so we need to deselect each stage manually. By default all stages are selected is it possible to have exact opposite, where all stages are deselected by default???

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"

1 Answers

I am afraid that there is no UI (like stage to run) method that can meet your needs.

You could try to add parameters to your Yaml Sample.

Here is an example:

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"

The parameters are used to determine whether to run these stages. You could add expressions before the stage to check if the parameter value could meet expression.

The default value is false. This means that the stage will not run by default.

Here is the result:

enter image description here

You can select the stage you need to run by clicking the selection box.

Update

Workaround has some limitations. When the select stage has depenencies, you need to select all dependent stages to run.

For example:

  - stage: 'QA'
    dependsOn: ['Test','Test1','Test2']

enter image description here

On the other hand, I have created a suggestion ticket to report this feature request. Here is the suggestion ticket link: Pipeline Deselect Stages By Default You could vote and add comment in it .

Related