Is there an option to fetch results of Azure DevOps pipelines?

72 views Asked by At

We had our pipelines all stored and triggered in Jenkins but switched to Azure DevOps some time ago.

Is there a way to create a "fetch-result-job" in Jenkins that will fetch te latest result of the Azure DevOps pipeline, so that I can integrate the Jenkins job in our monitoring tool?

We use an internal, self-developed monitoring tool, that only connects to Jenkins, as all of our other regular tests are stored there. Unfortunately, I havn't found a solution and there is also no way to integrate the Azure pipeline results directly.

1

There are 1 answers

0
Kevin Lu-MSFT On

I am afraid that there is no out-of-box method can directly integrate the Azure pipeline results.

Is there a way to create a "fetch-result-job" in Jenkins that will fetch te latest result of the Azure DevOps pipeline, so that I can integrate the Jenkins job in our monitoring tool?

To meet your requirements, you can use PowerShell script to run Rest API: Latest - Get to get the latest result of the Azure DevOps pipeline in Jenkins.

For example:

$token = "PAT"

$url="https://dev.azure.com/{Organization}/{Project}/_apis/build/latest/{DefinitionID}?api-version=7.1-preview.1"

$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))

$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Get  -ContentType application/json

echo $response.result

The Rest API can return all related information of the latest Pipeline Run. You can set the script output based on your requirement.

In Jenkins, you can use the PowerShell Plugin to run the PowerShell script.