#冲刺创作新星# Install gitlab-runner on centos7 原创

GabrielWu
发布于 2022-9-26 10:43
浏览
0收藏

Gitlab CICD状态pending

显示并未有任何可用runner

#冲刺创作新星# Install gitlab-runner on centos7-鸿蒙开发者社区

添加官方repository

curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh" | sudo bash

检查当前gitlab版本

[root@gitlab ~]# rpm -qa |grep gitlab
gitlab-ee-12.9.2-ee.0.el7.x86_64

安装特定版本gitlab-runner

yum list gitlab-runner --showduplicates | sort -r
sudo yum install gitlab-runner-12.9.1-1

注册到gitlab

获取相关信息

#冲刺创作新星# Install gitlab-runner on centos7-鸿蒙开发者社区

运行gitlab-runner register命令进行注册

[root@gitlab ~]# gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=12329 revisinotallow=97153df7 versinotallow=12.9.1
Running in system-mode.
# 输入gitlab的url地址
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://gitlab.xxxxxx.com/
# 输入注册的token
Please enter the gitlab-ci token for this runner:
13o3h7ZEiUVXGJfZe5Cy
# 输入对这个runner的描述,同时也是次runner的名字
Please enter the gitlab-ci description for this runner:
[gitlab.xxxxxx.com]: test_runner
# 输入runner的tag
Please enter the gitlab-ci tags for this runner (comma separated):
test
Registering runner... succeeded                     runner=K6cy5i3y
# 输入runner的executor
Please enter the executor: docker+machine, docker-ssh+machine, shell, docker, docker-ssh, parallels, ssh, virtualbox, kubernetes, custom:
docker
# 这里选择docker,需要制定默认的docker image来运行job(可以在.gitlab-ci.yml里修改需要用的image)
Please enter the default Docker image (e.g. ruby:2.6):
docker:19.03.13
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
注册完成后,自动生成配置文件

[root@gitlab ~]# cat /etc/gitlab-runner/config.toml
concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "maven"
  url = "http://gitlab.xxxxxx.com/"
  token = "13o3h7ZEiUVXGJfZe5Cy"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
  [runners.docker]
    tls_verify = false
    image = "maven:latest"
    extra_hosts = ["gitlab.xxxxxx.com:172.19.201.230"]
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
gitlab上也能看到此runner的信息

#冲刺创作新星# Install gitlab-runner on centos7-鸿蒙开发者社区

unregister runner

[root@gitlab ~]# gitlab-runner unregister --url http://gitlab.xxxxxx.com/ --token 13o3h7ZEiUVXGJfZe5Cy
Runtime platform                                    arch=amd64 os=linux pid=6978 revisinotallow=97153df7 versinotallow=12.9.1
Running in system-mode.

Unregistering runner from GitLab succeeded          runner=K6cy5i3y
Updated /etc/gitlab-runner/config.toml

©著作权归作者所有,如需转载,请注明出处,否则将追究法律责任
分类
标签
已于2022-9-26 10:44:17修改
3
收藏
回复
举报
回复
    相关推荐