Gitlab Pipelines allows you to define separate jobs and stages for your CI. No longer are we subjected to a single job that attempts to handle it all.
With this new functionality, we can create complex pipelines that change behavior based on many different factors, including the branch and commit message.
After using Gitlab Pipelines on a team for the better part of a year, here are some cool things I found that you may not know could be done.
Reuse a Docker Container for each stage
Originally we had a lengthy before_script that each job used. Each job took a few minutes to execute all the steps. Caching the /var/cache directories helped, but it still took time to install everything.
Eventually we decided on making a docker image as the first step, and reusing that image for each job.
make ci-container originally was a quick one-liner to build the docker container and push it to the registry:
Some troubles arose when trying to get our gitlab secret variables in the docker build process. That's where envsubst comes into play.
Deploy merge requests
One of the cool new features of Terraform is workspaces. This allows us to create entirely separate infrastructure for different branches. Interpolating the branch name allows terraform to avoid conflicts.
This has allowed us to completely migrate off of Jenkins. A year ago I wrote about a pipeline I was using. Being reliant on an old Jenkins server and not controlling all of the process through code was annoying. Jenkins Pipelines attempts to alleviate this, but it wasn't up to snuff for me.
Having the flexibility to codify complex stages and deploys easily in Gitlab has boosted our efficiency. We can focus more on getting features out to clients and less on maintaining all the moving ops parts.
Do you have any other Gitlab tricks or want more information on mine? Email or hit me up on twitter @thatarchguy