Can I set "Default branch for manual and scheduled builds" for a pipeline in Azure DevOps using an API?

631 Views Asked by At

Is it possible to set "Default branch for manual and scheduled builds" for a pipeline using the Azure DevOps REST API?

1

There are 1 best solutions below

0
On

Yes, when you update a build with Builds - Update Build Rest API you can send in the body the repository property, and inside it, you can set the defaultBranch:

repository: 
  checkoutSubmodules: false
  clean: "false"
  defaultBranch: "refs/heads/master"
  id: "7d9431dc-be40-48f6-a8dd-c12312424"
  name: "Test"

You can find all the repository options here.