Published on: May 7, 2020
5 min read
Under the covers look at the tooling behind creating releases from `.gitlab-ci.yml` with a Go command line interface
Release Management, a group within the Release stage, is about unblocking users as they continuously deliver value to their customers. A part of this can be seen in how users create Release tags to track production deployments and in that adoption of the Release features, users are deploying more with GitLab. We can also see a correlation between users adopting Releases to deploy with GitLab and leveraging more paid features.
We discovered the automation of creating these releases for our users was difficult and documented the needs for Release generation from the .gitlab-ci.yml
file in our epic, gitlab&2510. The highlights of the user pains around the release process include a:
Not only do users want to automatically create releases within their CI/CD, many of the other solutions such as Azure Pipelines, XebiaLabs, and Cloudbees, all feature a way to deploy and create releases from the YAML.
The Release Management team underwent a few calls with a GitLab Maintainer, Kamil Trzciński, to help decide the correct path forward. There were several scenarios we considered.
Option | Pros | Cons |
---|---|---|
Generate Release from Rails | 1. Simple addition of token and yaml job | 1. Rails would be too heavy 2. High potential for errors and slowness 3. Least performant option |
Create an independent CLI tool | 1. Independent and users can use it without downloading the whole Runner command 2. Can be owned by the Release team 3. The intention and domain of the CLI is very specific and users won't get confused. 4. We can have the code in any repo |
1. Maybe some code duplication from gitlab-runner-helper command to auth with CI_JOB_TOKEN |
Create a runner helper | 1. Much quicker since it's just copy/pasting a file and changing the command name and URL | 1. The user have to download the gitlab-runner-helper binary 2. Lots of actions for the user to take to use 3. Not as discoverable 4. Coupled and dependent on Runner team 5. It would require to follow the same release version scheme as GitLab Runner does |
We learned quickly that Rails was not the right place to generate a release as a result of performance and we also learned the logic was too much for the GitLab Runner to handle. This was discussed in a chat with Steve Azzopardi from the Runner Team, Sean Carroll from Release Management, and of course the product teammates.
The technical takeaways from this call included:
Thus, the team moved forward with the independent CLI and began developing this tool.
The release-cli tool is written in Go and can be called directly to create a Release via the API, given the right job token
and parameters are provided. The more likely way users will interact with this tool will be in the YAML file as a job:
release_upload:
image: registry.gitlab.com/gitlab-org/release-cli:v0.1.0
script:
- gitlab-releaser create --name="My Release" --description="My Release description"
release
node of .gitlab-ci.yml
.gitlab-ci.yml
configuration file is converted into Steps and made available via API endpoint.We currently have the first iteration of the release-cli complete, which looks like:
This MVC implemented via gitlab#199253, has enabled:
--name
and --description
parameters for a Release$CI_JOB_TOKEN
for authentication to the GitLab Releases API and $CI_PROJECT_ID
to create the ReleaseThe Release Management team will expand the tool to be able to manage many tasks for the Release generation. These features include:
:release
yaml as steps via gitlab#199250