Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deselect Stages By Default

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"

like image 563
Sar Avatar asked Aug 19 '20 17:08

Sar


People also ask

What are some of the stages involved in the DevOps delivery pipeline?

The DevOps pipeline typically has eight stages. In the Development phase, they are: plan, code, build, and test. In the Operations phase, the stages are: release, deploy, operate, and monitor.

What are stages in release pipeline in Azure DevOps?

Stages are the major divisions in your release pipeline: "run functional tests", "deploy to pre-production", and "deploy to production" are good examples of release stages.


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 .

like image 118
Kevin Lu-MSFT Avatar answered Oct 13 '22 23:10

Kevin Lu-MSFT