GitLab:Runner
GitLab의 Runner 에 대한 설명.
Reading GitLab Runner logs
When GitLab Runner is started as a foreground task (whether it's a locally installed binary or inside of a Docker Container), the logs are printed to the standard output. When GitLab Runner is started as a system service (e.g. with Systemd), the logs are in most cases logged through Syslog or other system logging mechanism.
With GitLab Runner started as a Docker based service, since the gitlab-runner ... command is the main process of the container, the logs can be read using the docker logs command.
For example, if GitLab Runner was started with the following command:
$ docker run -d --name gitlab-runner --restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /srv/gitlab-runner/config:/etc/gitlab-runner \
gitlab/gitlab-runner:latest
you may get the logs with:
One-line registration command
If you want to use the non-interactive mode to register a Runner, you can either use the register subcommands or use their equivalent environment variables.
To see a list of all the register subcommands, use:
To register a Runner using the most common options, you would do:
$ sudo gitlab-runner register \
--non-interactive \
--url "https://gitlab.com/" \
--registration-token "PROJECT_REGISTRATION_TOKEN" \
--executor "docker" \
--docker-image alpine:3 \
--description "docker-runner" \
--tag-list "docker,aws" \
--run-untagged \
--locked="false" \
If you're running the Runner in a Docker container, the register command would look like:
$ docker run --rm -t -i -v /path/to/config:/etc/gitlab-runner --name gitlab-runner gitlab/gitlab-runner register \
--non-interactive \
--executor "docker" \
--docker-image alpine:3 \
--url "https://gitlab.com/" \
--registration-token "PROJECT_REGISTRATION_TOKEN" \
--description "docker-runner" \
--tag-list "docker,aws" \
--run-untagged \
--locked="false"
Docker 로 수동 시작 및 수동 등록 (대화형)
RUNNER_INDEX=$1
docker run -d --name gitlab-runner${RUNNER_INDEX} --restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /opt/opm/gitlab-runner${RUNNER_INDEX}:/etc/gitlab-runner \
gitlab/gitlab-runner:latest
RUNNER_INDEX
에 명령행 인자 1~4 차례로 넣으면 된다.
생성된 컨테이너는 /etc/gitlab-runner/config.toml
파일이 갱신되면 자동으로 시작된다.
해당 컨테이너의 bash로 들어간다.
대화형으로 등록을 시작한다:
참고로 "registration token"은 "Gitlab 사이트 접속 > Admin Area > Overview > Runners" 안에 파란색 "Register an instance runner" 버튼을 클릭하면 토큰을 확인할 수 있다:
root@716fb8c086f1:/# gitlab-runner register
Runtime platform arch=amd64 os=linux pid=49 revision=91a27b2a version=16.11.0
Running in system-mode.
Enter the GitLab instance URL (for example, https://gitlab.com/):
https://git.your.com/
Enter the registration token:
bTx4m9x4p2Q6kHvRrMPD
Enter a description for the runner:
[716fb8c086f1]: runner4
Enter tags for the runner (comma-separated):
common
Enter optional maintenance note for the runner:
WARNING: Support for registration tokens and runner parameters in the 'register' command has been deprecated in GitLab Runner 15.6 and will be replaced with support for authentication tokens. For more information, see https://docs.gitlab.com/ee/ci/runners/new_creation_workflow
Registering runner... succeeded runner=bTx4m9x4
Enter an executor: instance, ssh, virtualbox, docker, kubernetes, docker+machine, docker-autoscaler, custom, shell, parallels, docker-windows:
docker
Enter the default Docker image (for example, ruby:2.7):
alpine:latest
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
Configuration (with the authentication token) was saved in "/etc/gitlab-runner/config.toml"
root@716fb8c086f1:/# exit
하이라이트 쳐진 곳이 사용자 입력이다.