Code releases using the Releasefile

With Release you can define a release from a Groovy-based DSL script, that describes all the phases, tasks, and task-groups in the release. This enables you to store release definitions as code in version control and gives you programmatic control over a release when creating it.

The Releasefile format is a defined structure for a .groovy file that can be used to create a release.

Using the Release DSL API you can create a custom release template file containing phases, multiple tasks, and task-groups. This enables you to launch a Releasefile Groovy script task that creates a release.

Example of a Releasefile

xlr {
    release("Hello world release") {
        description "Hello world release description"
        phases {
            phase {
                title "Sample"
                tasks {
                    manual("Manual task") {
                        description "Manual task description"
                    }
                }
            }
        }
    }
}

Create a release using Releasefile

  1. In the Release GUI, go to Design > Templates and open a template.
  2. Add a new Groovy Script task to a phase. For more information about Groovy Script tasks, see Create a Groovy Script task.
  3. Create a release from the template and then start the release.

When the Groovy Script task becomes active, the script is executed and a new release is created.

Note: You can also start a release directly from a repository using a Releasefile. Create a master template that creates a release from the code for every commit, and add the Releasefile script to the template. For more information, see Create a release from a Git repository.

Example of a Releasefile containing a task that creates a release

xlr {
  release("Sample release with a Create release task") {
    tags 'important', 'test'
    description "Sample template created from Groovy DSL"
    variables {
      stringVariable('createdReleaseIdVar')
    }
    phases {
      phase("Sample") {
        tasks {
          createRelease('Release it!') {
            description "Let's create a new release"
            newReleaseTitle "New release from a create release task"
            startRelease false
            template "Test/Best Template" // can be path OR Id
            templateVariables {
              stringVariable("myVariable", "myValue")
              mapVariable("myMapVariable", [
                key1: "val1",
                key2: "val2"
              ])
            }
            releaseTags "dev", "mobile", "stage"
            createdReleaseId variable('createdReleaseIdVar')
          }
        }
      }
    }
  }
}

Example of a Releasefile that creates a release with multiple phases

Note: By using the it iterator in the array, you can create multiple phases or tasks.

xlr {
  release("Sample release with a Create release task") {
    tags 'important', 'test'
    description "Sample template created from Groovy DSL"
    variables {
      stringVariable('createdReleaseIdVar')
    }
    phases {
    ['dev', 'qa', 'prd'].each {
        phase(it) {
          tasks {
            manual("Manual task") {
              description "Manual task description"
            }
          }
        }
      }
    }
  }
}

Importing templates in DSL format

You can export a template in DSL format. This enables you to view the DSL code corresponding to an existing template. For more information, see Release REST API. You can also see the current Releasefile from a template using the Releasefile view

Templates and trigger permissions

Importing DSL templates requires the user to have the permissions related to the items in the templates. In the case of triggers, permissions only exist at the folder level. For more information, see permissions for templates and releases.

If you import a template to a global scope - that is, not contained in a folder - and the template contains triggers, the template will be imported with an error, and the triggers will not be included in the imported assets.

Additionally, if you import a template into a folder, and you do not have trigger permissions, the DSL template will import with an error, and the triggers will not be included in the assets.