8

I have a Release pipeline with ~20 stages. Depending on the kind of release we are doing, we decide to run some subset of these stages.

Running each stage is expensive and we do not want to run it unless absolutely necessary.

Is there a direct way to disable some stages at the time of kicking off the release, so that we execute only the absolute necessary stages in the release?

If not, then what is the best programmatic way of achieving this behavior?

riQQ
  • 9,878
  • 7
  • 49
  • 66
Pranav Raj
  • 781
  • 1
  • 8
  • 19

3 Answers3

7

Currently, there is no option to disable the stages based on the conditions. I'd suggest you can submit feedback for this feature

As Daniel Suggest you should create separate release pipelines for your use case

Another option is to you can define that conditions in the task level with your stages to skip.

For Example,

You have 3 stages:

  • DEV
  • QA
  • PROD

Each Stage have 2 task:

  • Task 1
  • Task 2

Let say if you don't want to deploy in QA.

Then you can define your custom condition for the 2 Tasks in QA in order to skip the execution.

You can refer my answer for working with custom conditions.

Jayendran
  • 9,638
  • 8
  • 60
  • 103
4

It is very simple: Just use "condition" false or true; it will skip your stage; e.g.,

stages:
- stage: "CreateTemplates"  
  condition: "false"

click here for stage condition example

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
3

When starting the pipeline through the ADO webinterface, ADO now lets you specify which stages to run. ADO screenshot: select stages to run

If you prefer to select the stages programmatically, then you can use conditions. https://learn.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&tabs=yaml

stages:
- stage: A

# stage B runs if A fails
- stage: B
  condition: failed()

# stage C runs if B succeeds
- stage: C
  dependsOn:
  - A
  - B
  condition: succeeded('B')
Grilse
  • 3,491
  • 2
  • 28
  • 35