Skip to main content
Version: 4.5

How to trigger a prerequisite pipeline from with a pipeline

In some cases, the build of an application might require that another component first be built in a separate pipeline. Version 3.6 introduces this capability in the form of a required: section (under extends.parameters) of the YAML in the azure-pipelines.yml file.

If the required: section of YAML is specified, then at the beginning of the Continuous Integration stage of the pipeline a request will be issued to Azure DevOps to initiate the build of another pipeline in the same project. The built artifact of that other pipeline can optionally be downloaded into the working space of the current pipeline to satisfy any dependencies of the current pipeline on that artifact.

The structure of the required: YAML section looks like the following (provided values in the example below are the default values):

required:
branch:
timeoutInMinutes: 10
buildId:
wait: true
refreshSeconds: 60
downloadArtifact: false
parameters: |
.
.
.

NOTE: The numeric pipeline identifier (pipelineId) of the prerequisite pipeline to be run must first be retrieved for the other pipeline and then defined in the required: YAML section of the current pipeline as the buildId. In order to find this numeric identifer, in the web user interface of Azure DevOps, navigate to the prerequisite pipeline and note the URL showing in the browser. In that URL will be a query parameter named definiionId and the value assigned to that parameter is the pipelineId.

Additional notes:

  • The required buildId parameter, which has no default, is the numeric identifier (pipelineId) of the pipeline to run under the same project as the current pipeline
  • If the branch parameter is not provided, the name of the current pipeline's branch will be assumed
  • The parameters parameter is a multi-line list of key=value pairs of any additional parameters required by the prerequisite build pipeline
  • The wait paremeter indicates whether the current pipeline will wait for the completion of the prerequisite pipeline (if true, which is the default) or continue asynchronously (if false)
  • The downloadArtifact parameter indicates whether to retrieve the resulting build artifact (if true) into the current build's working space in a sub-directory named /required
  • The refreshSeconds parameter sets the interval (in seconds) at which the current pipeline will check the status of the requested prerequisite pipeline for completion
  • [NOT YET IMPLEMENTED] The timeoutInMinutes parameter sets a time limit (in minutes) that the current pipeline will wait for the completion of the requested prerequisite pipeline - Note that this parameter is not currently supported and the current pipeline will wait indefinitely