534. 【DevOps】配置gitlab-runner

一、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是否可以选择无标记的作业】勾上,不然作业会阻塞

[附加]解决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
  • 重启runnner
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值