Creating an Azure Pipeline using the Azure DevOps REST API is possible, but badly documented. This post goes through how to do this.
The documentation for creating an Azure Pipeline using the Azure DevOps API is somewhat lacking. However it isn't actually too hard, you just need the recipe.
Here's a curl to make you a pipeline:
Looking at the above there's two things you need:
- A personal access token. You can make one of those here: https://dev.azure.com/organisation-name/_usersSettings/tokens (where
organisation-nameis the name of your organisation)
makepipeline.jsonfile, which contains the details of the pipeline you want to create:
Let's talk through the significant properties above:
folder- can be
nullif you'd like the pipeline to be created in the root of Pipelines; otherwise provide the folder name. Incidentally a
nullwill be translated into a value of
\\which appears to be the magic value which represents the root.
name- your pipeline needs a name
path- this is the path to the yaml pipelines file in the repo. Note we're creating the pipeline itself here; what's actually in the pipeline sits in that file.
repository.id- this is the guid that represents the repo you're creating the pipeline for. You can find this out by going to your equivalent https://dev.azure.com/organisation-name/project-name/_settings/repositories (substituting in appropriate values) and looking up your repository there.
repository.name- the name of your repo
When you execute your curl you should be returned some JSON along these lines:
And inside Azure DevOps you'll now have a shiny new pipeline: