1

Run Pipeline Rest API - execute with branch name In our project, we are triggering pipeline through Runs REST API, following the steps mentioned in this page - https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/run%20pipeline?view=azure-devops-rest-6.0 . Now, we created the pipelines in feature branch and tried to invoke using the above API, we are getting below exception.

{
"$id": "1",
"innerException": null,
"message": "An error occurred while loading the YAML build pipeline. File /delete.yml not found in repository https://dev.azure.com/{}/{}/_git/{} branch refs/heads/master version 201d2723d992a6ce0575838046970367098296a.",
"typeName": "Microsoft.Azure.Pipelines.WebApi.PipelineValidationException, Microsoft.Azure.Pipelines.WebApi",
"typeKey": "PipelineValidationException",
"errorCode": 0,
"eventId": 3000
}

When we add the pipeline yml file in master branch, we are able to trigger it using the API. But if we should not use the master branch, and use a different branch, how we can pass the branch parameter in this API call?

James Z
  • 12,209
  • 10
  • 24
  • 44
  • Does this answer your question? [How do you specify the sourceBranch for a Run of Pipelines via the REST API?](https://stackoverflow.com/questions/66445303/how-do-you-specify-the-sourcebranch-for-a-run-of-pipelines-via-the-rest-api) – Vince Bowdren Jul 06 '22 at 23:33
  • Hi Kushal Billakanti, and welcome to Stack Overflow! – Vince Bowdren Jul 06 '22 at 23:33
  • I've found a question about, I think, precisely the same issue; I hope the answer (that you need to specify the 'self' repository on the POST body) is useful to you. – Vince Bowdren Jul 06 '22 at 23:34
  • Hi Kushal, any update on this, have you checked my answer? Does it answer your question – Bowman Zhu-MSFT Jul 18 '22 at 01:54

1 Answers1

1

I am able to reproduce your issue:

enter image description here

Reason:

Each pipeline is based on a specific YML file. If you call the rest api to run the pipeline based on one branch of the repo, you must make sure there is a same name YML file in the branch.

The situation on my side:

enter image description here

enter image description here

enter image description here

Let me know whether this can solve your issue.

Bowman Zhu-MSFT
  • 4,776
  • 1
  • 9
  • 10