Azure DevOps API to Trigger Multi Repo changing branches
Asked Answered
P

1

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.

Presentiment answered 22/4, 2022 at 22:2 Comment(0)
G
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":{}}
Grenoble answered 24/4, 2022 at 7:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.