Azure Pipeline to trigger Pipeline using YAML

后端 未结 4 1266
遇见更好的自我
遇见更好的自我 2021-02-05 07:12

Attempting to trigger an Azure pipeline when another pipeline has been completed using a YAML. There\'s documentation indicating that you can add a pipeline resource with:

4条回答
  •  猫巷女王i
    2021-02-05 07:53

    Microsoft documentation says that YAML is the preferred approach. So, instead of going for the build-trigger option let's understand the, little bit confusing, YAML trigger. The following tags will work from the original question and now with a bit easier documentation:

    resources:
      pipelines:
      - pipeline: aUniqueNameHereForLocalReferenceCanBeAnything
        project: projectNameNOTtheGUID
        source: nameOfTheOtherPipelineNotTheDefinitionId
        trigger:
          branches:
            include:
            - master
            - AnyOtherBranch
    

    The documentation from Microsoft is confusing and the IDs are numerous. At times they want the Project GUID at times the project name. At times they want the pipeline name and at times the pipeline definition Id. But they use the same name for the variable (project and pipeline). And on top of that they write documentation that does not make it easy to guess which one to use the best way is to trial and error.

    I think to avoid the confusion in other places I'm giving example of another place in the pipeline you refer to the same variables with different values. In the DownloadArtifact task, you need to use the project GUID and the pipeline definition Id as shown below:

    - task: DownloadPipelineArtifact@2
          inputs:
            source: specific (a literal constant value not the pipeline name)
            project: projectGUIDNOTtheProjectName
            pipeline: numericDefinitionIdOfPipelineNotPipelineNameOrUniqueRef
            runVersion: 'latest'
    

    Just look at how they used the same variables in a different way, but both referring to a pipeline and in my case the same exact pipeline. That could create confusion and to avoid stumbling into the next issue I give it here for clarification.

提交回复
热议问题