Nilotpal
Nilotpal

Reputation: 3588

Need to call multiple pipelines from another pipeline : How to trigger resources for ADO pipeline

I need to trigger multiple pipelines from another pipeline. For this i got ADO resources in YAML to configure. A resource is anything used by a pipeline that lives outside the pipeline.

Source : https://learn.microsoft.com/en-us/azure/devops/pipelines/process/resources?view=azure-devops&tabs=example#resources-builds

Steps i followed:

  1. Created a GIT repo and created a pipeline yaml on it. This is supposed to be a dummy repo that would only trigger other pipelines.

The yaml there is :

# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- none


resources:
  pipelines:
    - pipeline: 02-understanding-stages-pipeline
      project: azure-devops-kubernetes-terraform
      branch: master
      source: 02-understanding-stages-pipeline
      trigger:
        branches:
          - master
        stages:
          - Build
          - DevDeploy

Error in YAML

An error occurred while loading the YAML build pipeline. The array must contain at l 
least one element. Parameter name: stages

02-understanding-stages-pipeline is another pipeline in another project. I need to trigger and set of other such pipelines from this pipeline.

Question :

  1. Suggestions as how to trigger pipelines from other pipelines
  2. Any idea how to resolve the error i get
  3. What are source and pipeline under pipelines? Can explain briefly?

Thanks in advance!!

Upvotes: 0

Views: 1248

Answers (1)

Krzysztof Madej
Krzysztof Madej

Reputation: 40849

Suggestions as how to trigger pipelines from other pipelines

You can use Trigger Build Task extension as following:

- task: TriggerBuild@3
displayName: 'Trigger a new build of Validate-BuildVariable Update'
inputs:
    buildDefinition: 'Your build name'
    useSameBranch: false
    branchToUse: master
    waitForQueuedBuildsToFinish: true
    authenticationMethod: 'OAuth Token'
    password: $(System.AccessToken)

Or Rest API

POST https://dev.azure.com/{organization}/{project}/_apis/pipelines/{pipelineId}/runs?api-version=6.0-preview.1

Any idea how to resolve the error i get

I made a test and this works for me:

trigger: none


resources:
  pipelines:
    - pipeline: pipelineUnderstanding
      branch: master
      source: kmadof.dm-so-47-multi-stage
      trigger:
        branches:
          - master
        stages:
          - Build
          - Deploy
steps:
- script: echo 'siema'

I would suggest you to check your stages if your pipelie has exactly as you wrote here.

What are source and pipeline under pipelines? Can explain briefly?

Source is

name of the pipeline that produces an artifact

Pipeline is

identifier for the resource used in pipeline resource variables

It is just an alias of resource object. Please check it here

Upvotes: 1

Related Questions