Gitlab-CI实现组件自动推送

一、安装gitlab-runner

1.1 下载gitlab-runner

bash 复制代码
#查看自己的系统
go env GOARCH

#amd64下载
sudo curl --output $GOROOT/bin/gitlab-runner "https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-amd64"

#arm64下载
sudo curl --output $GOROOT/bin/gitlab-runner "https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-arm64"

sudo chmod +x $GOROOT/bin/gitlab-runner
cd $GOROOT/bin
gitlab-runner install
gitlab-runner start
#查看gitlab-runner是否正常启动
gitlab-runner status

通过终端下载比较慢,建议通过浏览器下载。

amd64下载地址:https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-amd64

arm64下载地址:https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-arm64

1.2 gitlab-runner注册到服务器

注册过程中要用到gitlab-ci的URL和Token

获取gitlab-ci的Token: 项目主页 -> Sttings -> CI/CD -> Runners Expand

注册Runner

bash 复制代码
0.---开始注册 [root@iZ2zectqga6hz17svze9jdZ ~]# gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=18056 revision=43b2dc3d version=15.4.0
Running in system-mode.                            
                                                   
1--- 叫你输入服务器地址:Enter the GitLab instance URL (for example, https://gitlab.com/):
http://gitlab.cfuture.shop/   // 这里填你的服务器地址
2---叫你输入token: Enter the registration token:
6UKvXWMU69gxFFyTUyvM
3---叫你输入runner描述Enter a description for the runner:
[iZ2zectqga6hz17svze9jdZ]: seenew-ops
4---叫你输入tags的名称:Enter tags for the runner (comma-separated):
seenew-ops
5--这里照我下面写即可-Enter optional maintenance note for the runner:
runner by shell
Registering runner... succeeded                     runner=GR13489417QtPoCmD
6---这里照我下面写即可Enter an executor: custom, docker-ssh, ssh, docker+machine, kubernetes, docker, parallels, shell, virtualbox, docker-ssh+machine:
shell  // 输入shell
Runner registered successfully. // 这里提示成功了

激活Runner

bash 复制代码
gitlab-runner verify

二、通过gitlab-ci推送chart

项目内新建一个.gitlab-ci.yml文件,内容如下:

bash 复制代码
stages:
  - deploy

deploy-job:
  tags:
    - seenew-ops
  stage: deploy
  script:
    - sh $GOPATH/src/seenew-ops-k8s/mdcl/mdcl-ci.sh

tags是当前Job的标记,这个tags关键字是很重要,因为gitlab的runner会通过tags去判断能否执行当前这个Job

提交代码,查看是否执行gitlab-ci

三、踩坑记录

3.1 job一直pending,没有Runner处理

● 首先考虑的是不是Runner没有激活,如果没有那么按上面方式处理

● 还可能是tag没有匹配到,Runner注册时是要填写绑定tag的,如果你在YML里面编写Job没有带上tag是不会有自定义Runner来处理。解决方法:给Job加tags

● Runner状态为stop

3.2 Runner启动报错

原因:安装的时候放在/usr/local/bin目录下,启动时权限不够,修改日志输出的目录。如下以我本地为例:

bash 复制代码
原因:安装的时候放在/usr/local/bin目录下,启动时权限不够,修改日志输出的目录。如下以我本地为例:

修改runner的安装地址和日志输出路径(原来是在/usr/local/bin目录)

修改完成后执行

bash 复制代码
launchctl unload /Users/jiangjunyu/Library/LaunchAgents/gitlab-runner.plist
launchctl load -w /Users/jiangjunyu/Library/LaunchAgents/gitlab-runner.plist
gitlab-runner stop
gitlab-runner start
gitlab-runner status
相关推荐
Xu_youyaxianshen1 小时前
Git 零基础常用指令手册(Gitee / GitHub 通用 )
git·gitee·github
阿里嘎多学长2 小时前
2026-07-22 GitHub 热点项目精选
开发语言·程序员·github·代码托管
小蠢驴打代码2 小时前
记忆库能通过测试,不等于回答值得信:Coding Agent Memory 的两层评估设计
github·ai编程
武子康2 小时前
Copilot Code Review 从固定 Reviewer 演进为可编程 Runtime,仓库控制面、Setup 供应链、Runner 资源和 MCP 工具同时被纳入审查决策
人工智能·github·aigc
不厌 -_-4 小时前
gitlab中怎么创建MR提交模板
gitlab·mr
wangruofeng13 小时前
opencodex 解锁 Codex 任意模型,一个本地代理打通 Claude/Kimi/GLM/DeepSeek
llm·github·openai
一点一木15 小时前
从60首歌到1个网站:输入你的故事,还你一首歌
前端·github
MC皮蛋侠客19 小时前
uv 系列(七):CI/CD、Docker 与私有索引——生产级交付
python·ci/cd·docker·uv
刘较瘦_19 小时前
AI 开发中的 Git Submodule 父子仓库模式:前后端分仓管理与协作实践
前端·github