pradeep rathinam
pradeep rathinam

Reputation: 1

How to get YAML code of a build pipeline?

I need to get the YAML script of a build pipeline. But 'View YAML' link is not visible when I select the pipeline. (It is visible when I select the agent/tasks under the pipeline.)

Is there any other way to get the YAML script or any way to enable the 'View YAML' link for the build pipeline?

Upvotes: 0

Views: 985

Answers (1)

Bhargavi Annadevara
Bhargavi Annadevara

Reputation: 5512

From this GitHub issue, it seems like a YAML build export was once possible but not anymore, and I could see it too. You can request it back here.

As a stopgap solution, I figured that one could still use the command line to get the build definition in yaml format. ;)

This is possible by using the azure-devops extension with Azure CLI. All you'd have to do is this:

# Add the Azure DevOps extension
az extension add --name azure-devops

# Confirm the installation
az extension list -o table

# Sign in to your account
az login

# (Optional) Configure defaults:
az devops configure --defaults organization=https://dev.azure.com/contoso project=ContosoWebApp

# List your build definitions
az pipelines build definition list -o table

# Get your build definition by ID in yaml format and save it in a file
az pipelines build definition show --id <id> -o yaml > builddef.yaml

And that would give a neat yaml with all you want. Hope this helps!

Upvotes: 1

Related Questions