Using YAML definition

You defined your first build pipeline using the task approach and the web designer, but you can also do it using YAML files.

 

When you use YAML, your pipeline is completely defined inside the YAML file, which is managed like a standard code file (it is stored in your Git repository and versioned like every other code file in your projects).

YAML is a human-readable data serialization format used in configuration files that use whitespace indentation to define their structure. For more information, go to https://yaml.org/.

A YAML file that describes a pipeline has the following structure:

Pipeline
└-- Variables
└-- Trigger
└-- Jobs
└-- Job
Steps
└-- Task
└-- Task
└-- Job
Steps
└-- Task
└-- Task

The job collections contain all the agent definitions, while the steps collections contain the tasks. 

For example, the pipeline you defined in the previous section will be as follows:

You can create your YAML file from scratch or start from the task pipeline. Every agent definition or task definition in the designer has a View YAML option you can use to generate the YAML snippet:

If you want to create your pipeline using YAML, you can create the pipeline as you did in the previous section, but you must choose YAML as a template instead of choosing Azure Functions:

Select the YAML definition file from your repository:

You can find more information about the schema reference for YAML in Azure DevOps at https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema.