6

I have a simple Azure Pipeline containing two stages:

  • Stage 1: Build
  • Stage 2: Run tests

Stage 1 builds the source code and pushes the binaries to Azure Artifacts. Stage 2 downloads the binaries of Stage 1 and runs multiple tests against them, using different jobs for different tests:

  • Job 1: Run tests for module A
  • Job 2: Run tests for module B
  • Job 3: Run tests for module C

These jobs are completely indepent of each other and run in parallel.

If all stages and jobs succeed, how can I manually trigger Job 3 in Stage 2 without triggering Stage 1 and Job 1 and 2 of Stage 2 again?

One ugly work around might be to use variables and somehow run a new pipeline, skip stage 1 if the variables are set and download the binaries from a previous pipeline. Are there better approaches?

Edit: There is a similar topic ongoing on ms dev community: https://developercommunity.visualstudio.com/idea/697467/manually-triggered-stages-in-yaml-multi-stage-pipe.html?childToView=903723#comment-903723

Tobias von Falkenhayn
  • 1,355
  • 5
  • 26
  • 59

2 Answers2

2

You can do what you are after with multi-stage pipelines if you pull the individual Jobs that exist in your current Stage 2 up into their own independent Stages.

Once you do that, you can then manually trigger them independently for reruns. enter image description here

Or if you had a need, you can also start a new run with only a subset of the stages. enter image description here

Eric Smith
  • 2,340
  • 12
  • 16
  • While I kind of like the idea, this seems more than a workaround. Aren't stages supposed to run one after another? Because I want to be able to run the tests in parallel. – Tobias von Falkenhayn Feb 03 '20 at 07:58
  • Ah I saw now its possible to run stages in parallel: https://learn.microsoft.com/en-us/azure/devops/pipelines/process/stages?view=azure-devops&tabs=yaml However, it still feels like a workaround since conceptually wise stages should run on after another I guess. – Tobias von Falkenhayn Feb 03 '20 at 11:23
  • Stages are the smallest atomic body of work that you can rerun on demand manually. And yes you can run them in parallel. But I guess you might be after something slightly different based on your edit link. – Eric Smith Feb 03 '20 at 12:56
0

If you define release pipeline in yaml , you can through adding condition: false to disable/skip a job in multiple-job pipeline.

- job: Foo  
  condition: false

For details , you can refer to this case.

Then you can choose which stages to run when running multi-stages pipeline ,through this, you can skip Stage1.

enter image description here

Hugh Lin
  • 17,829
  • 2
  • 21
  • 25