At work we are using GitLab Comunity Edition hosted on our servers. GitLab includes Git repository management, code reviews, issue tracking, wikis, plus GitLab CI, a continuous integration and deployment tool similar to Jenkins or TeamCity.
Being responsible with architecting and implementing the infrastructure for our web application, I spent the last days implementing the continuous integration/deployment pipeline. Here is just a short tutorial about how to install GitLab Runner, an application which processes builds. It can be deployed separately and works with GitLab CI through an API. In order to run tests, you need at least one GitLab instance and one GitLab Runner. The installation is done on SUSE Linux Enterprise Server 12 but should work on openSUSE, as well.
Even if on their website, SUSE is not mentioned, the binary, writen in GO, is working perfectly fine.
- download the binary and save it in /usr/local/bin/
# wget -O /usr/local/bin/gitlab-ci-multi-runner https://gitlab-ci-multi-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-ci-multi-runner-linux-amd64
- let's make it executable
# chmod +x /usr/local/bin/gitlab-ci-multi-runner
- check to see if is working
# gitlab-ci-multi-runner --version Version: 1.3.2 Git revision: 0323456 Git branch: stable-1-3 GO version: go1.6.2 Built: Tue, 28 Jun 2016 14:03:09 +0000 OS/Arch: linux/amd64
- create a GitLab CI user which will be responsible for our automatic builds and automatic deployments
# useradd -m deploy # passwd deploy New password: ...
- now we have to register the Runner. But before to do that we need a specific token and a "coordinator" URL which is generated by GitLab. In order to get them go to: Your GitLab Project -> Settings -> Runners, see the screenshot below.
# gitlab-ci-multi-runner register Running in system-mode. Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/ci): https://your-server-where-gitlab-is-installed/ci Please enter the gitlab-ci token for this runner: [your-unique-token] Please enter the gitlab-ci description for this runner: [our-little-gitlab-runner]: Please enter the gitlab-ci tags for this runner (comma separated): Registering runner... succeeded runner=fD_qnhkt Please enter the executor: docker+machine, docker-ssh+machine, docker, docker-ssh, parallels, shell, ssh, virtualbox: shell Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
- run the runner as a service
# gitlab-ci-multi-runner install --user=deploy --working-directory=/home/deploy/gitlab-runner
- start the service
# gitlab-ci-multi-runner start
- check if the runner is running
# ps aux | grep gitlab root 25687 1.5 0.1 64192 14584 ? Ssl 20:10 0:00 /usr/local/bin/gitlab-ci-multi-runner run --working-directory /home/deploy/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitlab-runner --syslog --user deploy
- check if build started (after a few seconds)
# ls -ltr /home/deploy/gitlab-runner/builds/ total 4 drwxr-xr-x 3 deploy users 4096 Jul 6 20:10 baf1e27f
I didn't mentioned until now but you also need a .gitlab-ci.yml in your repository. Check the available documentation.