English 中文(简体)
如何使AZDO管道在同一分行中触发另一个管道?
原标题:How to make an AZDO pipeline trigger another on the same branch?

I have two AZDO pipelines, each based on a Github repository with two branches, staging and production. Each pipeline runs, and uses Build.SourceBranch to identify the branch and then uses this to deploy to the same-name environment. I want to make the second pipeline trigger when the first pipeline completes, running for Staging when the first pipeline was on staging, and so on. However this does not happen.

我的第一个管道(ZAZDO称第一管道)利用这一管道确定部署的环境:

trigger:
  branches:
    include:
    - staging
    - production
variables:
- name: isProduction
  value: $[eq(variables[ Build.SourceBranch ],  refs/heads/production )]
- name: isStaging
  value: $[eq(variables[ Build.SourceBranch ],  refs/heads/staging )]

第二管道(ZAZDO称第二管道)利用:

trigger:
- staging
- production

resources:
  pipelines:
  - pipeline: contentPipeline   # Name of the pipeline resource
    source: firstpipeline       # Name of the triggering pipeline
    trigger: 
      branches:
        include:
        - staging
        - production
variables:
  - name: isProduction
    value: $[eq(variables[ Build.SourceBranch ],  refs/heads/production )]
  - name: isStaging
    value: $[eq(variables[ Build.SourceBranch ],  refs/heads/staging )]

However, what I find is that the second pipeline does not trigger at all when the first pipeline completes successfully.

My questions

  • Is my second pipeline trigger defined correctly?
  • If the first pipeline completes on the staging branch, will it trigger the second pipeline for the staging branch as well?
  • Will Build.SourceBranch be set to refs/heads/staging or just staging ?
  • Why is the second pipeline not triggering? Do I need to also put something in the first pipeline?
问题回答

我把这两条管道建成。

trigger:
  branches:
    include:
    - staging
    - production
variables:
- name: isProduction
  value: $[eq(variables[ Build.SourceBranch ],  refs/heads/production )]
- name: isStaging
  value: $[eq(variables[ Build.SourceBranch ],  refs/heads/staging )]

stages:
- stage: A
  jobs:
  - job: A1
    steps:
    - script: |
        echo "isProduction: $(isProduction)"
        echo "isStaging: $(isStaging)"
        echo "Build.SourceBranch $(Build.SourceBranch)"

以及

trigger:
- staging
- production

resources:
  pipelines:
  - pipeline: contentPipeline   # Name of the pipeline resource
    source: firstpipeline       # Name of the triggering pipeline
    trigger: 
      branches:
        include:
        - staging
        - production
variables:
  - name: isProduction
    value: $[eq(variables[ Build.SourceBranch ],  refs/heads/production )]
  - name: isStaging
    value: $[eq(variables[ Build.SourceBranch ],  refs/heads/staging )]

stages:
- stage: A
  jobs:
  - job: A1
    steps:
    - script: |
        echo "isProduction: $(isProduction)"
        echo "isStaging: $(isStaging)"
        echo "Build.SourceBranch $(Build.SourceBranch)"
        echo "production"

因此,我指此点。

“entergraph

以及 then

Is my second pipeline trigger defined correctly?

It is all depends how you named this in Azure Pipelines. If your first pipeline is firstpipeline 以及 second is contentpipeline than yes.

If the first pipeline completes on the staging branch, will it trigger the second pipeline for the staging branch as well?

Yes.

When you define a resource trigger, if its pipeline resource is from the same repository (say self) as the current pipeline, triggering follows the same branch 以及 commit on which the event is raised. But, if the pipeline resource is from a different repository, the current pipeline triggers on the default branch of the self repository.

Link here

建设。 来源 应设立分支机构,以重新评价/标题/老化或只是 st?

页: 1

isProduction: True
isStaging: False
Build.SourceBranch refs/heads/production

Why is the second pipeline not triggering? Do I need to also put something in the first pipeline?

你们是否确信管道的名称是正确的? 不是Myaml文档,而是输电管网门户。 你不必再补充一点。





相关问题
Team foundation server in the cloud?

We have been using TFS on our own server for a while. We would like to move it in the cloud. Is there any good hosted service? Note: we would like to import all our source and projects

热门标签