一、Docker 安装 runner
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 gitlab/gitlab-runner:latest
二、进入容器内部创建一个配置文件(这一步可能不需要,直接可进行下一步)
[root@qijing0 ~]# docker exec -it 0e /bin/bash
root@0ea31614bb53:/# touch /etc/gitlab-runner/config.toml
三、注册runner
[root@qijing0 ~]# docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register
Runtime platform arch=amd64 os=linux pid=7 revision=6d480948 version=15.7.1
Running in system-mode.
Enter the GitLab instance URL (for example, https://gitlab.com/):
http://192.168.3.1:10000/
Enter the registration token:
GR1348941J1DsxtL4DTjyshfq48kv
Enter a description for the runner:
[92fb28d0fb0a]: deploy-runner
Enter tags for the runner (comma-separated):
deploy
Enter optional maintenance note for the runner:
qijing
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://gitlab.com/gitlab-org/gitlab/-/issues/380872
Registering runner... succeeded runner=GR1348941J1DsxtL4
Enter an executor: instance, kubernetes, ssh, virtualbox, docker+machine, docker-ssh+machine, shell, custom, docker, docker-ssh, parallels:
docker
Enter the default Docker image (for example, ruby:2.7):
centos:7
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"
四、使用runnner
- 点击【浏览群组】、点击【CI/CD】、点击【Runnner】
五、运行runner运行在没有标签的项目上
- 把【指示此runner是否可以选择无标记的作业】勾上,不然作业会阻塞
[附加]解决runner Failed to connect to gitlab.xxxx port xxx after ms: Operation timed out
vim /srv/gitlab-runner/config/config.toml
[[runners]]
name = "runner-deploy"
url = "http://192.168.3.1:1000/"
id = 7
token = "GP-6ZBkZsAjyxs9hvdrW"
token_obtained_at = 2022-12-24T01:22:36Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "docker"
[runners.custom_build_dir]
[runners.cache]
MaxUploadedArchiveSize = 0
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "centos:7"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
extra_hosts = ["gitlab.xxxx.cn:192.168.3.1"] #添加上这一行
shm_size = 0
docker restart yourcontainer
网友评论