GitLab runner

Install

wget https://packages.gitlab.com/runner/gitlab-runner/gpgkey -O - | apt-key add -
cat <<EOF> /etc/apt/sources.list.d/gitlab-runner.list
deb https://packages.gitlab.com/runner/gitlab-runner/ubuntu/ xenial main
EOF
apt update
apt install gitlab-runner

List / delete gitlab-runner

# List GitLab runner configuration
gitlab-runner list
 
# Delete all GitLab runner
gitlab-runner unregister --all-runners

Instlal with Ansible
https://github.com/panticz/ansible/tree/master/roles/gitlab-runner
https://github.com/haroldb/ansible-gitlab-runner

Get token from GitLab server
http:///admin/runners

# configure DNS for GitLab server
echo "10.0.1.12 gitlab.example.com gitlab" >> /etc/hosts

Register
https://docs.gitlab.com/runner/register/

# shell
sudo gitlab-runner register \
  --non-interactive \
  --url "http://gitlab/" \
  --registration-token "XAr8-bZz2PbpFSrYRFMt" \
  --executor "shell" \
  --description "runner1" \
  --tag-list "shell,runner" \
  --run-untagged \
  --locked="false"
 
# docker
    # https://docs.gitlab.com/runner/register/
    # https://docs.ansible.com/ansible/latest/modules/gitlab_runner_module.html
 
# fix directory permissions
chown gitlab-runner. /var/lib/gitlab-runner
 
gitlab-runner register \
    --non-interactive \
    --run-untagged \
    --docker-privileged \
    --url https://git.example.com/ \
    --registration-token XXXXX \
    --executor docker \
    --docker-image docker:latest \
    --description gitlab-runner1-dev \
    --tag-list "docker,privileged" \
    --locked="false"
#     --cache-dir "cache" \
 
    - name: Register gitlab-runner
      command: >
        gitlab-runner register
          --non-interactive
          --url "{{ gitlab_runner_server_url }}"
          --registration-token "{{ gitlab_runner_registration_token }}"
          --executor "docker"
          --docker-image alpine:latest
          --description "{{ gitlab_runner_description }}"
          --tag-list "docker,runner"
          --run-untagged="true"
          --locked="false"
          --access-level="not_protected"

.gitlab-ci.yml

before_script:
  - date > /tmp/date
 
step1:
  script:
    - touch /tmp/x

GitLab runner configuration

/etc/gitlab-runner/config.toml
/etc/systemd/system/gitlab-runner.service

Log

# Logfile
docker logs gitlab-runner  -f

Max Archive size

# grep -r client_max_body_size  /etc/gitlab/gitlab.rb /var/opt/gitlab/nginx/conf/*
/etc/gitlab/gitlab.rb:nginx['client_max_body_size'] = '1024m'
/var/opt/gitlab/nginx/conf/gitlab-http.conf:  client_max_body_size 1024m;
Admin > Settings > Continuous Integration and Deployment > Maximum artifacts size (MB)

Ansible
https://docs.ansible.com/ansible/latest/modules/gitlab_runner_module.html

Links
https://docs.gitlab.com/ce/ci/runners/
https://docs.gitlab.com/ee/ci/README.html
https://docs.gitlab.com/ee/ci/yaml/#variables