0

I have to call this Azure Devops REST api which requires runId and what is this runid and how to get it

REST API ENDPOINT - GET https://learn.microsoft.com/en-us/rest/api/azure/devops/test/runs/get-test-run-by-id?view=azure-devops-rest-7.1&tabs=HTTP

I have seen this and this SO links but it is not working & there is no clear way to get runid in Azure DevOps Pipelines.Even if i call this end point to get all runs results, how i would filter current running pipeline.

I need to get runid of the current running pipeline to invoke above REST API.

F11
  • 3,703
  • 12
  • 49
  • 83

1 Answers1

0

You can find the Run Id in the URL of the pipelines you’ve ran.
You can visit the select Pipeline section of Azure Dev-Ops below:-
Pipelines > Select one Pipeline

enter image description here

enter image description here

Select any Pipeline from the Runs> you will find the runId in the Azure DevOps url like below :-

enter image description here

https://dev.azure.com/{organization}/{project}/_build/results?buildId={runId}

If you want to call Azure DevOps Rest API to get the run ID by pipeline you can call the below endpoint:-

You can get the Pipeline in the url of your pipeline like below:-

https://dev.azure.com/<organization-name>/<project-name>/_apps/hub/ms.vss-build-web.ci-designer-hub?pipelineId={pipelineID}&branch=main

enter image description here

GET https://dev.azure.com/{organization}/{project}/_apis/pipelines/{pipelineId}/runs?api-version=7.0

Reference:-
Runs - List - REST API (Azure DevOps Pipelines) | Microsoft Learn

SiddheshDesai
  • 3,668
  • 1
  • 2
  • 11
  • You mean we can get runid by querying above rest endpoint with pipeline id, but how to get pipeline id in yaml pipeline? – F11 Feb 10 '23 at 12:08
  • You can make use of pipelineId: $(System.PipelineId) and steps: - script: echo "The pipelineId is: $(pipelineId)" also refer this SO link- https://stackoverflow.com/questions/54563230/how-do-i-identify-my-azuredevops-id-for-a-pipeline-in-ado-pipelines# – SiddheshDesai Feb 10 '23 at 15:04
  • test run id is different than build id, build id in the above url is different than run id that we have to pass in https://dev.azure.com/{organization}/{project}/_apis/test/runs/{runId}?api-version=7.1-preview.3 – F11 Feb 10 '23 at 15:21
  • Any insights here? - https://developercommunity.visualstudio.com/t/get-pipeline-specific-run-id/1331800 – SiddheshDesai Feb 10 '23 at 15:28