If you have a GitLab instance using your self-signed certificate, you have to add it to machines pulling the code, and to the runner, so that they can securely communicate with the server.
I'm using docker based gitlab-runner, to add the cert to it follow these steps:
Make sure you have the certificate, I'm using the root pem certificate file.
Copy the file to your docker box and rename it to ca.crt (yes, change the file extension!)
Next step is to run the temporary container, mounting the config directory and registering it with gitlab:
Run:
docker run --rm -t -i \
-v /srv/gitlab-runner/config:/etc/gitlab-runner \
-v /path-to-your-cert/ca.crt:/etc/gitlab-runner/certs/ca.crt \
--name gitlab-runner gitlab/gitlab-runner register
You are going to be asked a few questions now: (borrowed from gitlab documentation). You can get the required information from your gitlab serverhttps://your-gitlab.url/admin/runners
- Enter your GitLab instance URL:
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com ) https://gitlab.com
- Enter the token you obtained to register the Runner:
Please enter the gitlab-ci token for this runner xxx
- Enter a description for the Runner, you can change this later in GitLab’s UI:
Please enter the gitlab-ci description for this runner [hostame] my-runner
- Enter the tags associated with the Runner, you can change this later in GitLab’s UI:
Please enter the gitlab-ci tags for this runner (comma separated): my-tag,another-tag
- Enter the Runner executor:
Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell: docker
- If you chose Docker as your executor, you’ll be asked for the default image to be used for projects that do not define one in .gitlab-ci.yml:
Please enter the Docker image (eg. ruby:2.1): alpine:latest
The final step is to run the runner:
Run:
docker run -d --name gitlab-runner --restart always \
-v /srv/gitlab-runner/config:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /path-to-your-cert/ca.crt:/etc/gitlab-runner/certs/ca.crt \
gitlab/gitlab-runner:latest
Links:
https://docs.gitlab.com/runner/register/index.html#docker