GitLab CI - Install Runner



Description

GitLab runner is a build instance which is used to run the jobs over multiple machines and send the results to GitLab. In this chapter, we will discuss about how to install runner in the GitLab CI.

Installing Runner

Step 1 − First, login to your GitLab server using SSH (Secure Shell).

Step 2 − Update the repository by using the below command −

$ sudo apt-get update -y
GitLab Runner

Step 3 − Next, install the required dependencies −

sudo apt-get install wget curl gcc checkinstall libxml2-dev
sudo apt-get install libxslt-dev libcurl4-openssl-dev
sudo apt-get install libreadline6-dev libc6-dev libssl-dev
sudo apt-get install libmysql++-dev make build-essential
zlib1g-dev
sudo apt-get install openssh-server git-core libyaml-dev
sudo apt-get install redis-server postfix libpq-dev libicudev

Step 4 − Now, install the Ruby by creating a directory under /tmp folder −

mkdir /tmp/ruby && cd /tmp/ruby

Step 5 − Install the Ruby package with the below command −

curl --progress http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.bz2 | tar xj
cd ruby-2.0.0-p353
./configure disable-install-rdoc && make && sudo make install

Step 6 − After installing the Ruby, install the package manager for Ruby −

sudo gem install bundler 
GitLab Runner

Step 7 − Now create a new user to run the runner instead of running as root user. (For security reasons, we are creating new user) −

sudo adduser disabled-login gecos 'GitLab CI Runner' gitlab_ci_runner

Step 8 − Login with new user −

sudo su gitlab_ci_runner
cd ~/

Step 9 − Now clone the actual code after installing all dependencies −

git clone https://gitlab.com/gitlab-org/gitlab-ci-runner.git && cd gitlab-ci-runner

Step 10 − Next, install the gems for the runner −

bundle install -deployment

Step 10 − Your need to start runner automatically whenever the server restarts by creating the init.d file −

cd /gitlab-ci-runner
sudo cp ./lib/support/init.d/gitlab_ci_runner /etc/init.d/gitlab-ci-runner
sudo chmod +x /etc/init.d/gitlab-ci-runner
sudo update-rc.d gitlab-ci-runner defaults 21

Step 11 − Now you can start the runner by using the below command −

sudo service gitlab-ci-runner start
Advertisements