Manage release template as code

This tutorial is intended to help you get started with DevOps as Code in Release. It describes how to generate a DevOps as Code YAML file from an existing Release template and manage it in source control.


For this tutorial, you need:

  • A running Release server
  • The XL CLI client

Modify an existing template as code

This tutorial assumes you have an existing template in Release. In this example, we will use the bundled templates in the Samples & Tutorials folder, but you can easily substitute them with templates of your own.

First, we will generate a YAML file from the template using the XL CLI.

Use the following command:

xl generate xl-release -p 'Samples & Tutorials' -n 'Sample Release Template with Deploy' -f sample-release.yaml

This will create a file called sample-release.yaml.

Open the file in your favorite editor. The first lines should look like this:

apiVersion: xl-release/v1
kind: Templates
- name: Sample Release Template with Deploy
  type: xlrelease.Release
  description: Major and minor release template.
  scheduledStartDate: 2018-11-12T09:00:00Z
  - name: QA
    type: xlrelease.Phase
    - name: Wait for dependencies
      type: xlrelease.GateTask
      team: Release mgmt.

The YAML file is generated without any folder information. Change the header section to point to the folder it’s coming from, so we will be updating the original template when sending it back.

apiVersion: xl-release/v1
kind: Templates
  home: Samples & Tutorials

Now change the line that says:

- name: Wait for dependencies

To the following:

- name: Wait for development to finish

Use the xl apply command to send the file back to Release:

$ xl apply -f sample-release.yaml

Check the template in the Release UI. The title of the first task should now read “Wait for development to finish”.

Store the template in source control

The next step is to store the DevOps as Code YAML file in source control and have the changes applied automatically by your favorite build tool.

See Use an XL wrapper scripts for details on how to do this.