Elliot Nelson
Elliot Nelson

Reputation: 11557

Retrieve Build Cause/Reason from Azure Pipelines?

I am using the Azure DevOps REST API, for example:

curl -X GET 'https://dev.azure.com/MyOrg/MyProject/_apis/pipelines/ID/runs/ID?api-version=6.0-preview.1'

In the result, there does not seem to be any mention of the parameters passed into the pipeline, or the build cause/reason. I've tried setting variables to the value of the parameters and that doesn't seem to show up either, and fiddling with the API version string hasn't yielded anything.

Is there a way to programmatically retrieve information about trigger reason and parameters using the API? Without this, it seems impossible to build any backend data (for example, to show the % of users using your pipeline via the azure portal or via PR triggers).

Upvotes: 0

Views: 618

Answers (1)

Cece Dong - MSFT
Cece Dong - MSFT

Reputation: 31003

You could use Builds - Get api instead:

GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}?api-version=6.0

You would get triggerInfo and reason in the response.

Upvotes: 1

Related Questions