Quick gitlab runner setup
Gitlab runner is a continuous integration tool that I've found it to be a lot easier than Jenkins to wrap my head around when it comes to deploying source code to demo machines.
In this scenario gitlab runner it pulls per-project source code to a runner machine then executes any of the commands specified in .gitlab-ci.yml from source code root directory.
Here's a sample configuration of updating source code on buildout-based Plone 5 project:
stages:
- deploy
001 stop plone server:
stage: deploy
script:
- ./bin/supervisorctl shutdown
cache:
paths:
- .installed.cfg
- bin/*
- develop-eggs/*
- downloads/*
- eggs/*
- parts/*
- var/*
002 rebuild project:
stage: deploy
script:
- ./bin/buildout -v -c buildout_prod.cfg
- ./bin/supervisord
cache:
paths:
- .installed.cfg
- bin/*
- develop-eggs/*
- downloads/*
- eggs/*
- parts/*
- var/*
I've been repeating a task of installing a runner for a particular projects -- setting up a gitlab runner, and I've found it to be spread over at least 3 documents:
- Install GitLab Runner using the official GitLab repositories
- Registering runners
- Gitlab Runner commands
To get runner installed and registered, the following steps should be taken:
- Add gitlab-runner repo
CentOS 7
# curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
Debian
# curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
- Install gitlab-runner package
CentOS 7
# yum install gitlab-runner
Debian
# apt-get install gitlab-runner
- Remove default gitlab-runner configuration (as root) and run it as a selected user. This step is not required if you're using default configuration, but in my case I have already setup environment for user 'alex' and it is a lot easier to run jobs there.
# gitlab-runner uninstall
# gitlab-runner install --working-directory=/home/alex --user=alex
- Register gitlab runner with a gitlab server
# gitlab-runner register
For the last step the registration information is found in <gitlab server>/admin/runners
This document provides instructions on how to lock shared runners to specific projects -- https://docs.gitlab.com/ee/ci/runners/