1

The Azure Devops pipeline is already defined with multiple repos and working as expected from Azure DevOps Tool, this Tool allows to change the branch names while triggering the build.

I am working on automating the build using a equivalent APIs and I would like to change the branch names for both the repos while triggering a build.

I am able to achieve apart of this by passing the sourceBranch for 1st repo using json request as mentioned below. I am not sure how to update the branch name for second repo in multiple repo build pipeline setup.

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

{
    "sourceBranch": "<branch-name>",
    "definition": {
        "id": 6
    }
}

enter image description here

Any help on this really appreciated.

Anvesh K
  • 42
  • 6

1 Answers1

3

It's impossible in the build api, but it's available in the Runs - Run Pipeline API:

POST https://dev.azure.com/{organization}/{project}/_apis/pipelines/{pipelineId}/runs?api-version=7.1-preview.1

In the body you can specify resources:

"resources":{"repositories":{"devops":{"refName":"refs/heads/test-branch","version":""},"self":{"refName":"refs/heads/master"}}},"variables":{}}
Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114