GitLab-Runner安装及使用
2024-10-12 10:28:08
Git_Lab CI Setting
根据该教程本地下载并安装 gitlab-runner.exe
在GitLab远程仓库页面点击 setting-> CI/CD ->runner Expand ,然后拷贝 Runner setup URL , registration token到第三步输入
install gitlab-runner.exe and register on local PC
# at the git runner folder
gitlab-runner.exe install
gitlab-runner.exe register
...enter Runner setup URL
...enter registration token
...enter runner description
...enter runner tag (Unique Identification)
...enter script executor(depend on script language)
## automatically generate config.toml after success修改runner中对应的config.toml
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = " PC_1"
url = "https://gitlab.test.com/"
token = "test123456789"
executor = "shell"
builds_dir = "E:\\GitLab-Runner\\builds"
cache_dir = "E:\\GitLab-Runner\\cache"
environment = ["SCE_PHYRE=E:\\GitLab-Runner\\builds\\test"] #设置runner无法读取的环境变量
shell = "powershell" # 配置gitlab-ci.yml script会使用的语言 runner为win系统时建议使用powershell
[runners.custom_build_dir]
enabled = true # 自定义runner本地存储代码的位置
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
在远程仓库根目录下创建t
gitlab-ci.yml
文件
#ex:
compile:
script:
- cd /d "D:\test" # 执行runner命令,自定义
- echo test
tags:
- PC_1 # 选择“gitlab-runner.exe register”中设置的“runner tag”
variables:
GIT_CLEAN_FLAGS: -ffdx -e cache/ # 清空缓存
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PROJECT_NAME # 设置仓库下载地址
配置成功后在本地目录下启动runner
gitlab-runner.exe run --syslog # 不可关闭当前terminal
注:
修改config.toml、注册runner,需要关闭“gitlab-runner.exe run --syslog”(在当前终端Ctrl+C)
一个gitlab-runner.exe可注册多个项目的runner,但不能过多, 同一台主机可以存在多个gitlab-runner.exe(不同目录,仓库地址也不能冲突)
config.toml
中的“\”需要使用“\\”
CMD
gitlab-runner.exe install
gitlab-runner.exe register
gitlab-runner.exe start
gitlab-runner.exe restart
gitlab-runner.exe stop
gitlab-runner.exe run --syslog
ssh-keygen -t rsa -C xxx@xxx.com.cn #
.gitlab-ci.yml (Git_lab Code)
# 定义 stages
stages:
- test
- compile
test:
stage: test
script:
- echo test
tags:
- PC_1 deploy:
stage: compile
script:
- cd /d "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE"
- devenv.com "E:\GitLab-Runner\builds\test\test.sln" /rebuild "Release|x64"
tags:
- PC_1
variables:
GIT_CLEAN_FLAGS: -ffdx -e cache/ # clear git code
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PROJECT_NAME # code dir
QA:
删除register
在gitlab->setting->ci->runner->expand 删除对应runner
删除runner本地config.toml文件的对应runner配置
最新文章
- 我的第一段jQuery代码
- MongoDB固定集合(capped collection)
- mysql 批量导出建表语句 (视图,函数同理)
- js最新手机号码、电话号码正则表达式
- Android性能优化之运算篇
- afxmessagebox和messagebox
- PHP 获取远程文件的大小的3种方法
- Django设置
- CDH 5.5.1 Yum源服务器搭建
- C# 调试
- 05-XML遍历递归显示到TreeView上(XDocument类)
- 【百度地图API】——如何让标注自动呈现在最佳视野内
- bootstrap + angularjs + seajs构建Web Form前端(1)
- [HAOI 2011]Problem c
- 【干货】基于Owin WebApi 使用OAuth2进行客户端授权服务
- Vue在线客服系统【开源项目】
- C语言——数组名、取数组首地址的区别(一)
- python自学第11天-单线程并发、迭代器,序列化,获取路径
- awk、sed、grep三大shell文本处理工具之grep的应用
- Lucene 个人领悟 (三)
热门文章
- Markdown快速入门——我不学 甚至没这篇文章
- 【安全】漏洞复现及修复——CVE-2023-24055 keepass触发器注入获取明文密码
- Nginx12 openresty使用lua-resty-http模块
- springcloud-alibaba
- C#小知识之中英文转换、去空格
- Spring Boot 防止接口被恶意刷新、暴力请求
- Shell命令-常用操作
- CF845F - Guards In The Storehouse
- EF Corexxxxnstance with the same key value for {'Id'} is already being tracked.
- .NET控制台程序秒变asp.net core站点