首页 技术 正文
技术 2022年11月18日
0 收藏 606 点赞 3,525 浏览 4931 个字

本文转自:https://blog.csdn.net/qq_21816375/article/details/84308748

本编是继gitlab cicd (一)系列之安装gitlb之后,基于安装gitlab-runner进行CI的部署教程(executor:docker)

系统

[root@gitlab-runner-64 ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

安装docker
请参考安装docker 17.03.2.ce教程

安装gitlab rpm包

[root@gitlab-runner-64 ~]# curl -s https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo 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.nwsuaf.edu.cn
* extras: mirrors.nwsuaf.edu.cn
* updates: mirrors.nwsuaf.edu.cn
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
runner_gitlab-runner-source/signature | 951 B 00:00:00 !!!
runner_gitlab-runner-source/primary | 175 B 00:00:02
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.nwsuaf.edu.cn
* extras: mirrors.nwsuaf.edu.cn
* updates: mirrors.nwsuaf.edu.cn
Package yum-utils-1.1.31-46.el7_5.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

The repository is setup! You can now install packages.

安装gitlab-runner

root@gitlab-runner-64 ~]# yum install gitlab-runner -y
1
启动gitlab-runner

[root@gitlab-runner-64 ~]# systemctl start gitlab-runner
[root@gitlab-runner-64 ~]# systemctl status gitlab-runner
● gitlab-runner.service – GitLab Runner
Loaded: loaded (/etc/systemd/system/gitlab-runner.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2018-11-20 15:33:55 CST; 1min 15s ago
Main PID: 27906 (gitlab-runner)
Memory: 4.9M
CGroup: /system.slice/gitlab-runner.service
└─27906 /usr/lib/gitlab-runner/gitlab-runner run –working-directory /home/gitlab-runner –config /etc/gitlab-runner/config.toml –service gitla…

Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]: Running in system-mode.
Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]: Running in system-mode.
Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]:
Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]:
Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]: Configuration loaded builds=0
Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]: Configuration loaded builds=0
Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]: Listen address not defined, metrics server disabled builds=0
Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]: Listen address not defined, metrics server disabled builds=0
Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]: Listen address not defined, session server disabled builds=0
Nov 20 15:33:55 gitlab-runner-64 gitlab-runner[27906]: Listen address not defined, session server disabled builds=0

注册gitlab

[root@gitlab-runner-64 ~]# gitlab-runner register
Runtime platform arch=amd64 os=linux pid=28891 revision=cf91d5e1 version=11.4.2
Running in system-mode.

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://10.39.47.63
Please enter the gitlab-ci token for this runner:
xiwkMztdhy5ipdgpsjHC
Please enter the gitlab-ci description for this runner:
[gitlab-runner-64]: gitlab-runner-test
Please enter the gitlab-ci tags for this runner (comma separated):
my-tag,another-tag
Registering runner… succeeded runner=xiwkMztd
Please enter the executor: docker+machine, kubernetes, docker, parallels, shell, ssh, virtualbox, docker-ssh+machine, docker-ssh:
docker
Please enter the default Docker image (e.g. ruby:2.1):
golang:latest
Runner registered successfully. Feel free to start it, but if it’s running already the config should be automatically reloaded!
#注册完成之后,gitlab-runner的配置文件会改变
[root@gitlab-runner-64 ~]# cat /etc/gitlab-runner/config.toml
concurrent = 1
check_interval = 0

[session_server]
session_timeout = 1800

[[runners]]
name = “gitlab-runner-test”
url = “http://10.39.47.63”
token = “477e1b6bba858703fd609e7ff991e4”
executor = “docker”
[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]

从页面可以查看到

新建一个项目,项目根目录的.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’

1
2
3
4
5
6
7
8
9
10
11

把该项目加入刚刚加的gitlab-runner里

查看执行结果

end
参考
Configuration of your jobs with .gitlab-ci.yml
runner-register
安装
生成token
———————
作者:qinzhao168
来源:CSDN
原文:https://blog.csdn.net/qq_21816375/article/details/84308748
版权声明:本文为博主原创文章,转载请附上博文链接!

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,077
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,552
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,401
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,176
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,813
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,896