1

I am trying to get build pipeline details using pipeline azure devops api, it is giving correct result for classic pipelines.

https://dev.azure.com/{orgname}/{projectId}/_apis/build/Definitions/{buildId}?includeAllProperties=True&includeLatestBuilds=True&api-version=6.0";

bug in case of yaml pipeline i am not able to get what is written in yaml. I want to get details of task added as yaml

Thanks

Arvind Singh
  • 53
  • 1
  • 1
  • 7

2 Answers2

3

One way that I have seen to get access to the pipeline yaml code via the API is to grab the 1st log for a build.

It has all of the code from your azure-pipeline.yml file.

It also has any templates that you referenced in your pipeline file expanded out inline as well as all of the variables listed in all of your variable yaml files.

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

Set {{LogId}} to 1 and you will get all of the info listed above.

CSR_Reaper
  • 31
  • 4
1

Get the pipeline details using this method below (ref https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/pipelines/get?view=azure-devops-rest-6.0)

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

Which will give you the YAML file location and repository in the additional properties of configuration object of the pipeline.

scorpio
  • 1,587
  • 2
  • 15
  • 27
  • 2
    but it's not will give the yaml tasks. – Shayki Abramczyk Jun 28 '21 at 12:13
  • that will be only available when you edit the Yaml either through VScode (with Azure devops extension installed) or edit the YAML from Azure DevOps directly – scorpio Jun 28 '21 at 22:27
  • @scorpio not quite true. The answer of CSR_Reaper is correct. Using his approach, the yaml file describing the pipeline will be in the response body. – Noah Ispas Nov 24 '22 at 17:49