What Are YAML Files Used for in VB Studio ?

All YAML files must reside in the .ci-build directory in the root directory of any hosted Git repository’s main branch. YAML files in other branches will be ignored. Any text file that has a .yml file extension and resides in the main branch’s .ci-build directory is considered to be a YAML configuration file. Each YAML file can contain configuration data for exactly one job or one pipeline. You can have YAML files in multiple Git repositories, or use a separate Git repository to host all your YAML configuration files. You cannot, however, use an external Git repository to host YAML files. Because these configuration files are stored using Git, you can track changes made to the job or pipeline configuration and, if a job or pipeline is deleted, you can use the configuration file to recreate it.

The build system constantly monitors the project’s Git repositories. When it detects an update to a file with the .yml extension in the .ci-build directory of a Git repository’s main branch, it scans the file to determine if it is a job or a pipeline, and creates or updates the corresponding job or pipeline. First, it verifies whether the job or the pipeline of the same name (as in the configuration file) exists on the Builds page. If the job or the pipeline exists, it’s updated. If the name of the job or pipeline has changed in the configuration file, it’s renamed. If the job or the pipeline doesn’t exist, it’s created.

Note: Jobs and pipelines created with YAML can’t be edited on the Builds page. They must be edited using YAML. Similarly, jobs and pipelines created on the Builds page can’t be edited using YAML.

YAML stores data as a key-value pair in the field: value format. A hyphen (-) before a field identifies it as an array or a list. It must be indented to the same level as the parent field. To indent, always use spaces, not tabs. Make sure that number of indent spaces before a field name matches the number of indented spaces in the template. YAML is sensitive to number of spaces used to indent fields. Also, the field names in a YAML file are similar to the field names in the job configuration user interface:


name: MyFirstYAMLJob
vm-template: Basic Build Executor Template
git:
- url: "https://mydevcsinstance-mydomain/.../scm/employee.git"
steps:
- shell:
    script: "echo Build Number: $BUILD_NUMBER"
- maven:
    goals: clean install
    pom-file: "employees-app/pom.xml"

If you’re editing a YAML file on your computer, always use a text editor with the UTF-8 encoding. Don’t use a word processor.

Here are some additional points to consider about YAML files before you begin creating or editing them:

A commit when pushed to the patchset_1 branch triggers a build of the MyFirstYAMLJob job.