简体   繁体   中英

Forking two stages back into one azure pipeline

I'm currently working on a azure devops yaml pipeline. The structure of the pipeline looks something like this: yaml管道的结构

As you can see I have multiple "forks" and in one case I want to bring the "forked ways" back into one. (before the download_from_source stage). The noapproval stage is kind of unnecessary and I want to delete it.

Is there a way to achieve this without having an extra stage? So it would look something like this?

新结构

Not exactly sure what you are trying to achieve but here is an example of how you can set variables in a stage and use them as conditions for future steps.

The approval check stage I assume runs some checks to validate if the pipeline should run. So if those checks pass, we can set an output variable and then use that variable to condition the download task. If the checks fail then approval=false and the download task will not run.

流水线图

pool: default
variables:
  system.debug: true

stages:
  - stage: check_package
    jobs:
    - job: check_package
      steps:
        - bash: echo "checking package"

  - stage: approval_check
    jobs:
    - job: bash
      steps:
      # run some checks and if succesful we can set set output variable approved=true
        - bash: echo "##vso[task.setvariable variable=approved;isOutput=true]true"
          name: approval

  - stage: download
    dependsOn: approval_check
    condition: and(succeeded(), eq(dependencies.approval_check.outputs['bash.approval.approved'], 'true'))
    jobs:
    - job: download
      steps:
        - bash: echo "Downloading"

  - stage: download2
    dependsOn: approval_check
    condition: 
    jobs:
    - job: download
      steps:
        - bash: echo "Downloading"

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