3

I have a parent pipeline which publish pipeline artifacts.

And the child pipeline which has a parent pipeline added as a resource pipeline and consumes the parent's artifacts.

I would like to programatically (by REST API) create a run of multistage child pipeline and provide the parent pipeline resource.

How to craft a request body for pipelines' run endpoint? According to ms docs PipelineResourceParameters contains only version? Are there any examples how to use it? Is it a resource name and buildnumber?

https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/run%20pipeline?view=azure-devops-rest-6.1#pipelineresourceparameters

Where can I find any examples of requests bodies?

fenrir
  • 246
  • 1
  • 9

1 Answers1

2

The pipeline resource is set in advance in the pipelines. By default, the pipeline will select last successful run as the resource. We can choose the pipeline resource version when we run the pipeline. enter image description here

Here is my request body sample:

{
  "resources":{
        "pipelines":{
            "Parent":{
                "version":"20201225.1"
            }
        }
    }
}

If you want to find the sample of Rest API, in addition to referring to the examples in the official documentation, you can also check the developer tool (F12) in the browser. For example, run a pipeline manually and check the rest api: enter image description here

Walter
  • 2,640
  • 1
  • 5
  • 11
  • 1
    It works. One note, the pipeline name (Parent) in the resources/pipeline is the pipeline identifier for the resource used in pipeline resource variables and not the name of the pipeline that produces an artifact. – fenrir Dec 31 '20 at 10:36
  • Yes, it only works when you use the pipeline alias (defined in YAML), not the pipeline name or id. – Rye bread Aug 16 '22 at 10:14