简体   繁体   中英

Manually triggered stages in Azure Devops YAML Pipelines

I'd like to recreate a pipeline that looks something like this in YAML.

发布管道

I have successfully recreated the first line (A) pipeline. A combination of dependsOn , environmentName , and environment approvals handles that. However, there doesn't seem to be a way to create the B and C pipelines in YAML.

I've seen several similar questions , but most were not quite what I was looking for or were very old had no solution. I suspect this isn't possible right now but wanted to ask to be sure.

You could control it per to the parameters, for example:

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

trigger:
  - none

variables:      # pipeline-level
  system.debug: true

stages:
- stage: Build
  jobs:
  - job: Build
    steps:
    - script: echo "hello to my first Build"
- stage: Test
  dependsOn:
    - Build
  jobs:
  - job: Test
    steps:
    - script: echo "test"
- ${{ if eq(parameters.stageTest, true) }}: 
  - stage: B1
    dependsOn: []
    jobs:
    - job: B1
      steps:
      - script: echo "B1"
  - stage: B2
    dependsOn:
    - B1
    jobs:
    - job: B2
      steps:
      - script: echo "B2"

The parameter is stageTest and you could set the value (check or uncheck) when queue pipepeline.

在此处输入图像描述

On the other hand, you also could skip stage when run pipeline: Skipping stages in a YAML pipeline

Put an approval in front of the first environment. It won't trigger until it's approved. That's as close as you're going to get right now.

I am afraid that it is currently impossible to implement the manually triggered stage like the UI of release pipeline in YAML pipeline.

At present, the function of specifying the stage to run is provided in yaml, but this only applies to manually triggered pipelines and cannot deploy the manual stage at any time as in the release pipleine.

According to your flow chart, you want your pipeline start with CI and keep the independence of manual stages will not affect the running of the pipeline. Splitting stages into multiple yaml pipelines should not be what you want, so you can follow the uservoice and vote for this ticket to look forward to the release of new features.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM