'What is the difference and relationship between an Azure DevOps Build Definition, and a Pipeline?

I am trying to automate a process in Azure DevOps, using the REST API. I think it should go like this (at least, this is the current manual process):

  • fork repo
  • create pipeline(s) based using YAML files in newly forked repo
  • run pipelines in particular way

I am new to the Azure DevOps REST API and I am struggling to understand what I have done and what I should be doing.

Using the REST API, I seem to be able to create what I would call a pipeline, using the pipeline endpoint; I do notice that if I want to run it, I have to interact with its build definition instead.

Also, looking at code other colleagues have written, it seems (though I may be wrong) like they are able to achieve the same by simply creating a build definition, and not explicitly creating pipeline.

This lack of understanding is driving me bonkers so I am hoping someone can enlighten me!

Question

What is the difference, and relationship, between a Build Definition and a Pipeline?


Additional info, I am not interested in working with the older Release Pipelines and I have tried to find the answer among the Azure DevOps REST API docs, but to no avail.



Solution 1:[1]

The pipelines endpoint is not very useful:

https://dev.azure.com/{Organization}/{ProjectName}/_apis/pipelines?api-version=6.0-preview.1

It will only give you a list of pipelines with very basic info such as name, ID, folder etc.

To create and update YAML pipelines you need to use the Build definitions endpoint. The IDs you use in the endpoint are the same IDs as the Pipelines endpoint uses.

Get definition, Get list, Create, Update:

https://dev.azure.com/{Organization}/{ProjectName}/_apis/build/definitions?api-version=6.0

(To create a working pipeline you must first Get an existing pipeline, modify the JSON you receive, then POST it as a new definition.)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rye bread