linux安装gitlab-runner最新保姆级教程

安装

安装教程来自gitlab官网,本文仅演示CentOS系统下安装gitlab-runner

自动安装

1.添加gitlab官方存储库

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

也可以配置yum源安装

sh 复制代码
vim /etc/yum.repos.d/gitlab-runner.repo
复制以下内容:

[gitlab-runner]
name=gitlab-runner
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/yum/el$releasever-$basearch/
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key

# 更新缓存
yum clean && yum makecache
# 安装最新
yum install -y gitlab-runner

2.安装gitlab-runner

此步骤是通过yum命令安装最新版本的GItlab Runner,想要安装指定版本请执行下一步

sh 复制代码
sudo yum install gitlab-runner

安装指定版本

sh 复制代码
# 通过'yum install gitlab-runner-×.×.×'指定版本号
sudo yum install gitlab-runner-15.11.0-1
手动安装

1.下载安装包

Runner部署包下载:https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/yum/el7-x86_64/

2.安装gitlab-runner rpm包

sh 复制代码
rpm -ivh gitlab-runner-16.3.1-1.x86_64.rpm
gitlab-runner install --working-directory /home/gitlab-runner --user root
gitlab-runner start
注册

安装完成Runner后,我们需要将其注册到gitlab上

sh 复制代码
# 执行交互式注册命令完成注册
[root@localhost ~]# gitlab-ci-multi-runner register

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):

http://192.168.12.141:9001/ # 你的gitlab地址

Please enter the gitlab-ci token for this runner:

*****yLxk5iajnAJS5*** # Token


Please enter the gitlab-ci description for this runner:

[localhost.localdomain]: focus-runner-des (runner的描述名称,随便DIY能有效区分就行)

Please enter the gitlab-ci tags for this runner (comma separated):

192.168.2.107 (runner的tags名称,随便DIY能有效区分就行)

Please enter the executor: docker-ssh, parallels, ssh, virtualbox, kubernetes, docker, shell, docker+machine, docker-ssh+machine:

shell (因为想用shell脚本执行,所以选择shell,选择shell的优点是共享服务器上安装的java、maven以及docker等应用)

gitaly钩子----提交代码检查

为所有存储库创建全局服务器挂钩:

  1. 在 GitLab 服务器上,转到配置的全局服务器挂钩目录。
  2. 在配置的全局服务器钩子目录中,为与钩子类型匹配的钩子创建目录。例如,对于pre-receive服务器挂钩,目录名称应为pre-receive.d
sh 复制代码
全局钩子
cd /var/opt/gitlab/gitaly/custom_hooks
mkdir pre-receive.d # 所有pre-receive钩子脚本目录
touch pre-receive
# vim 编辑脚本后保存
chmod +x pre-receive
相关推荐
热爱嵌入式的小许5 小时前
Linux基础项目开发1:量产工具——显示系统
linux·运维·服务器·韦东山量产工具
韩楚风9 小时前
【linux 多进程并发】linux进程状态与生命周期各阶段转换,进程状态查看分析,助力高性能优化
linux·服务器·性能优化·架构·gnu
陈苏同学9 小时前
4. 将pycharm本地项目同步到(Linux)服务器上——深度学习·科研实践·从0到1
linux·服务器·ide·人工智能·python·深度学习·pycharm
Pythonliu710 小时前
茴香豆 + Qwen-7B-Chat-Int8
linux·运维·服务器
我是哈哈hh10 小时前
专题十_穷举vs暴搜vs深搜vs回溯vs剪枝_二叉树的深度优先搜索_算法专题详细总结
服务器·数据结构·c++·算法·机器学习·深度优先·剪枝
郭二哈10 小时前
C++——模板进阶、继承
java·服务器·c++
挥剑决浮云 -10 小时前
Linux 之 安装软件、GCC编译器、Linux 操作系统基础
linux·服务器·c语言·c++·经验分享·笔记
立秋678911 小时前
Python的defaultdict详解
服务器·windows·python
Lansonli11 小时前
云原生(四十一) | 阿里云ECS服务器介绍
服务器·阿里云·云原生
john_hjy12 小时前
11. 异步编程
运维·服务器·javascript