成功最有效的方法就是向有经验的人学习!

CICD系列git-runner安装(二)

接上回
启动docker

[root@guilin ~]# systemctl start docker
[root@guilin ~]# systemctl enable docker

准备repo

[root@guilin ~]# curl -s https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | bash
Detected operating system as centos/7.
Checking for curl...
Detected curl...
Downloading repository file: https://packages.gitlab.com/install/repositories/runner/gitlab-runner/config_file.repo?os=centos&dist=7&source=script
done.
Installing pygpgme to verify GPG signatures...
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
runner_gitlab-runner-source/signature                                                                                                                |  836 B  00:00:00     
Retrieving key from https://packages.gitlab.com/runner/gitlab-runner/gpgkey
Importing GPG key 0xE15E78F4:
 Userid     : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
 Fingerprint: 1a4c 919d b987 d435 9396 38b9 1421 9a96 e15e 78f4
 From       : https://packages.gitlab.com/runner/gitlab-runner/gpgkey
Retrieving key from https://packages.gitlab.com/runner/gitlab-runner/gpgkey/runner-gitlab-runner-366915F31B487241.pub.gpg
runner_gitlab-runner-source/signature                                                                                                                |  951 B  00:00:01 !!! 
runner_gitlab-runner-source/primary                                                                                                                  |  175 B  00:00:01     
Package pygpgme-0.3-9.el7.x86_64 already installed and latest version
Nothing to do
Installing yum-utils...
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Package yum-utils-1.1.31-50.el7.noarch already installed and latest version
Nothing to do
Generating yum cache for runner_gitlab-runner...
Importing GPG key 0xE15E78F4:
 Userid     : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
 Fingerprint: 1a4c 919d b987 d435 9396 38b9 1421 9a96 e15e 78f4
 From       : https://packages.gitlab.com/runner/gitlab-runner/gpgkey
Generating yum cache for runner_gitlab-runner-source...

The repository is setup! You can now install packages.

安装gitlab-runner

[root@guilin ~]# yum install gitlab-runner -y

启动gitlab-runner

[root@guilin ~]# systemctl start gitlab-runner
[root@guilin ~]# systemctl status gitlab-runner

注册

[root@guilin ~]# gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=33111 revision=a987417a version=12.2.0
Running in system-mode.                            

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://10.150.7.5/
Please enter the gitlab-ci token for this runner:
RBmTj7Joyn-GNQ1m2QDY
Please enter the gitlab-ci description for this runner:
[guilin]: blog.ct99.cn.test.runner
Please enter the gitlab-ci tags for this runner (comma separated):
test-tag
Registering runner... succeeded                     runner=RBmTj7Jo
Please enter the executor: docker-ssh, ssh, docker-ssh+machine, shell, virtualbox, docker+machine, kubernetes, custom, docker, parallels:
docker
Please enter the default Docker image (e.g. ruby:2.6):
golang:latest
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!

注册后的配置文件

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

[session_server]
  session_timeout = 1800

[[runners]]
  name = "blog.ct99.cn.test.runner"
  url = "http://10.150.7.5/"
  token = "iAG5ykaGMQzxiVDAF9xS"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.docker]
    tls_verify = false
    image = "golang:latest"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]

file

将这个runner改为私有的。
file

新建一个项目在根目录下建立一个.gitlab-ci.yml文件

job:
  tags: 
    - test-tag ##注意这个是选择指定的runner
  services:
  - php:7
  - node:latest
  - golang:1.10
  image: alpine:3.7
  script:
  - echo '========== hello gitlab-runner'

file
把项目添加到gitlab-runner里
file
可以在jobs里面查看执行结果
file

file

file
参考资料

https://docs.gitlab.com/ee/ci/yaml/README.html
https://docs.gitlab.com/runner/register/
https://docs.gitlab.com/runner/install/index.html
https://docs.gitlab.com/ee/ci/runners/
赞(0) 打赏
未经允许不得转载:陈桂林博客 » CICD系列git-runner安装(二)
分享到

大佬们的评论 1

  1. #1

    GitLab 允许我们给 runner 设置标签,设置好后该 runner 只会执行拥有相同标签的任务。由于我们的 runner 只为我们自己的代码库服务,所以此处不做过多配置。留空即可。

    admin5年前 (2019-09-03)回复

全新“一站式”建站,高质量、高售后的一条龙服务

微信 抖音 支付宝 百度 头条 快手全平台打通信息流

橙子建站.极速智能建站8折购买虚拟主机

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册