Skip to content

gitlab

For now these are the steps of the last installation (dec 2021) on servert1

installation

Probably: you should download gitlab-ee debian package, but i already had it in aptitude so follow these steps.

install
EXTERNAL_URL="http://192.168.1.204/" apt-get install gitlab-ee

Note that this will use port 80 and will interfere with apache, so you might have to do http://192.168.1.204:4444/ or something, i did it wrong so i reconfigured...

Reconfigure it in /etc/gitlab/gitlab.rb

/etc/gitlab/gitlab.rb
external_url "http://192.168.1.204:4444/"

And run :

reconfigure
gitlab-ctl reconfigure
gitlab-ctl restart

Now give it some time, it will say for minutes 'too long to respond'. Finally you will get a login on the given url. Note that it's credentials are in .. code-block:

/etc/gitlab/initial_root_password

First thing to do is add a normal user. Admin -> Users -> New User Be sure to make it 'Admin' so you won't need root anymore.

gitlab-runner

Install this on a different system if possible, but local works.

install runner
# Download the binary for your system
sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64

# Give it permissions to execute
sudo chmod +x /usr/local/bin/gitlab-runner

# Create a GitLab CI user
sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash

# Install and run as service
sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
sudo gitlab-runner start

Finally you have to register the runner but you need the token from the gitlab server for that , so fill the REGISTRATION_TOKEN with that or just paste it in place.

register with server
sudo gitlab-runner register --url http://192.168.1.204:4444/ --registration-token $REGISTRATION_TOKEN

You will have to choose what executor to use here. Shell is the easiest one because of course you can run docker from the shell as well. But if docker is really the only tool used, docker might be a better executor.

Also shell gives this error :

error
ERROR: Job failed: prepare environment: exit status 1. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information

See : https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading

create ci/cd pipeline

First make sure you can see the runner just added in gitlab, not you don't get settings unless you are admin !

Settings -> CI/CD -> Expand the Runners.

Now you see "Available specific runners". Click the edit pencil : Especially to prevent errors with "This job is stuck" make sure the "Run untagged jobs" is enabled.

debug problems

Both the problem with the shell runner and the problem with "/bin/bash: line 114: docker: command not found" can be investigated by logging into the runner-server and becoming user gitlab-runner.

For instance this can be used to reproduce a docker socket error:

debugging
1
2
3
4
5
ssh servert1
sudo su 
su - gitlab-runner
cd builds/BMJUkAxq/0/kees/bhv # or similar for your build
docker build -f docker/app/Dockerfile -t bhv-app .

And it does output the sane as in the gitlab-runner console:

error
ERRO[0000] failed to dial gRPC: cannot connect to the Docker daemon. Is 'docker daemon' running on this host?: dial unix /var/run/docker.sock: connect: permission denied .

This, by the way, is how to solve that problem :)

fix socket problem
1
2
3
# as root, gitlab-runner has no sudo 
usermod -aG docker gitlab-runner
service docker restart

Note that this is a good way to tryout all your runner steps before running it on gitlab. Also note that the gitlab-runner finished way faster because it was already compiled on the runner machine itself.

However one specific error is : ERROR: Job failed (system failure): prepare environment: exit status 1. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information

TLDR: it says empty .bash_logout content (the clear makes it fail)

stop gitlab and runners

stop
1
2
3
4
5
gitlab-ctl status
gitlab-ctl stop
gitlab-ctl status
date
Sun 23 Jan 2022 06:29:36 PM CE

Monitor if this time gives a change in downtimes on both servert and hoek !!

I needed this to test if gitlab was causing network downtime on both caiway and xs4all interfaces.

This should tone down the noise on the servert1 machine as well.