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

Viewed 333

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.

2 Answers

If you want to create a pipeline you can do this using both of this. However, the difference is actually in terms of concept:

  • build definitions are part of first available flow which consist: build and release where build was responsible for building, testing and publishing artifact for later use in releases to deploy
  • pipeline are a new approach which leverage YAML designed process for building/testing/deploying code

More info you can find here - Whats the difference between a build pipeline and a release pipeline in Azure DevOps?

And for instance for this pipeline/build

https://dev.azure.com/thecodemanual/DevOps%20Manual/_build?definitionId=157

where definition id is 157

You will get reposnses in both endpoints:

https://dev.azure.com/{{organization}}/{{project}}/_apis/build/definitions/157?api-version=5.1

and

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

and in that term pipeline id = build id

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.)

Related