2
votes

I'm new to Azure DevOps REST API (and somewhat to REST in general) and have been asked to create a PowerShell script to create basic build pipelines. I've found that the documentation provided by Microsoft does not include a single example for creating build definitions, nor does it even provide a template for the JSON request body. I've read through all of the articles on Stack Overflow related to the topic that I can find, but none of them seem to provide a real answer to this issue.

If anyone could provide an example of the required request body, or a link to one, I can put the rest of it together.

Thanks.

1
The REST API documentation tells you what the request body should look like in the "request body" section. Alternately, you can create a build definition manually, export it as JSON, and use that as a baseline. Or you can use YAML builds, which defines the build in a source-controlled YAML file.Daniel Mann
Thanks, @DanielMann. Both good ideas, and I will try to learn from them. The YAML idea sounds good, but I only see one method for creating definitions in the API docs. I'll dig more into the documentation and see if I can figure this out.towerbe

1 Answers

1
votes

The documentation at https://docs.microsoft.com/en-us/rest/api/azure/devops/build/definitions/create?view=azure-devops-rest-5.0 does a pretty good job of explaining how to communicate with Azure DevOps to create a new build definition. The request body section of the documentation lists all the parameters you'd put into a REST call.

I would hazard that this feels like an odd question because it is unusual to create build definitions programmatically. You might want to check your assumptions and see if this is really what you want to do.