1、现象
fatal: unable to access 'https://github.com/homebrew/brew/':
2、解决
git config --global --unset http.proxy
git config --global --unset https.proxy
查看gitlab-runner是否成功:
user@users-MacBook-Pro ~ % gitlab-runner -h
查看gitlab-runner状态:
user@users-MacBook-Pro ~ % ps -ef | grep gitlab-runner
501 3658 3081 0 4:36PM ttys004 0:00.00 grep gitlab-runner
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/yum/el7/gitlab-runner-15.8.1-1.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/yum/el7/gitlab-runner-15.0.0-1.x86_64.rpm
yum -y install gitlab-runner-15.0.0-1.x86_64.rpm
#查看运行状态
systemctl status gitlab-runner
安装runner
sudo curl --output /usr/local/bin/gitlab-runner "https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-arm64"
创建runner
这个步骤需要在gitlab中进行,有三种的runner可以创建,分别是共享、组群和项目。
创建好后复制出gitlab地址和token,接下来注册时会用到。
注册runner
注册是最关键的步骤。
gitlab-runner register
然后按顺序输入内容完成创建过程:
首先输入URL,就是创建runner时复制的那个URL;
接下来输入token,就是创建runner时复制的那个token;
然后输入description,这个description可以理解为runner名,在list里会看到;
接下里就是输入最最重要的tags,这个tags在配置.gitlab-ci.yml时需要指定,不然会导致runner无法将修改提交给CI流水线;
然后让输入一个note,直接按enter跳过即可;
最后让选择executor,由于是在mac中,输入shell即可。
不出意外就会在本机成功创建出一个runner。
运行runner
gitlab-runner restart
gitlab-runner run
如果restart失败了不用管,继续run即可
启动gitlab-runner和关闭gitlab-runner ,查看gitlab-runner不同的状态
三、gitlab-runner设置用户为root
第二步安装gitlab-runner是会默认安装一个gitlab-runner用户,CI运行期间,会出现一些权限不足的问题,所以将gitlab-runner的默认用户设为root
卸载掉gitlab-runner默认用户
sudo gitlab-runner uninstall
首先通过 sudo su -把账户切换到root账户,这样才能执行下面的命令
重新安装gitlab-runner并将用户设置为root
gitlab-runner install --working-directory /home/gitlab-runner --user root
重启gitlab-runner
sudo service gitlab-runner restart
第3步执行完后,gitlab-runner已经开始运行,不需要手动运行。
ubuntu搭建gitlab-runnner:
Ubuntu搭建gitlab-Ci教程_gitlab runner ubuntu-CSDN博客
gitlab-runner注册成功,验证相关文件
1./Users/user/Library/LaunchAgents 路径下会有gitlab-runner.plist文件
2. ps -ef | grep gitlab-runner 查看 config.toml 所在路径
user@users-MacBook-Pro LaunchAgents % ps -ef | grep gitlab-runner
501 13477 1 0 Fri10AM ?? 1:38.56 gitlab-runner run
501 51729 1 0 4:28PM ?? 0:40.77 /usr/local/bin/gitlab-runner run --working-directory /Users/user --config /Users/user/.gitlab-runner/config.toml --service gitlab-runner --syslog
501 69890 53079 0 10:51AM ttys003 0:00.00 grep gitlab-runner
3. config.toml 文件包含了注册时填写的相关信息
user@users-MacBook-Pro .gitlab-runner % pwd
/Users/user/.gitlab-runner
user@users-MacBook-Pro .gitlab-runner % ls
config.toml
user@users-MacBook-Pro .gitlab-runner % cat config.toml
concurrent = 1
check_interval = 0
shutdown_timeout = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "TCOE"
url = "https://gitlab.prod-ss.welabts.net/"
id = 89
token = "fjbuxz-fCiPnqePg57aF"
token_obtained_at = 2024-02-05T06:39:52Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "shell"
[runners.cache]
MaxUploadedArchiveSize = 0
user@users-MacBook-Pro .gitlab-runner %
如果pipline出现pengding的情况
并且有下面的报错信息
This job is stuck because of one of the following problems. There are no active runners online, no runners for the protected branch, or no runners that match all of the job's tags: build
Go to project CI settings
解决方案:
点击runner的编辑按钮,勾选下面两个选项并且保存
、
需要把gitlab-ci.yml中的tags都删除,这样才能正常执行
Runners can be configured with tags of your choice when you first set them up. The purpose of tags:
in .gitlab-ci.yml
is to say, "only use runners with these tags". For example, if you need a job to run on a specific server, or have CUDA access, or some other special environmental thing that generic runners don't have, use tags. If that's not your intention then remove tags:
.
Gitlab job is stuck, no active runners, why? - Stack Overflow
安装gitlab-runner成功会在一下路径生成文件gitlab-runner.plist
Init already exists: /Users/user/Library/LaunchAgents/gitlab-runner.plist
gitlab-runner 启动报错
FATAL: Failed to start gitlab-runner: "launchctl" failed with stderr: Load failed: 5: Input/output error
Try running `launchctl bootstrap` as root for richer errors.
可以使用 launchctl start gitlab-runner启动
user@users-MacBook-Pro ~ % launchctl start gitlab-runner
user@users-MacBook-Pro ~ % launchctl status gitlab-runner
ps -ef | grep gitlab-runner 查看gitlab-runner进程
在 Gitlab CI 中,Runner 是 Job 的执行器, 也就是说 Job 的运行环境, 就是 Runner 的环境。
怎么将同一个 gitlab ci
中的 Job
运行在不同的 Runner 上
例如, 根据 操作系统 区分, job1
运行在 windows
上, job2
运行在 linux
上, 诸如此类。
使用 TAG 指定 runner
其实很简单, gitlab ci
中, 可以通过指定 tags
来设定运行条件, 满足了 tag
才能被执行。
而 ci
中的 tags
和可以和 runner
中的 tags
进行匹配
.gitlab-ci.yml
.gitlab-ci.yml
文件如下, 定义了一个 tar
stage , 下面有 三个 job
分别对应 三个 runner 的编译和打包环境。
注意, 这里使用的是 Runner 的
TAG
,不是 Runner 的名字
stages:
- tar
# .gitlab-ci.yml
tar.ivs:
stage: tar
script:
- /bin/bash ivs-1800-matrix-build.sh
tags:
- neuron-arm64 # 执行 ivs 的runner
tar.3519a:
stage: tar
script:
- /bin/bash hisi-3519a-build.sh
tags:
- 3519A # 执行 3519a 的 runner
tar.atlas:
stage: tar
script:
- /bin/bash atlas-500-matrix-build.sh
tags:
- edge # 执行 atlas 的 runner
Mvn命令行报错解决方案
Gitlab CI/CD runner : mvn command not found | 易学教程
https://www.e-learn.cn/topic/2237630
I notice that I tried to fix the problem by adding the before_script section in the .gitlab-ci.yml file :
before_script:
- export MAVEN_HOME=/usr/local/apache-maven
I add also the line :
environment = ["MAVEN_HOME=/usr/local/apache-maven"]
on the config.toml file.