windows 安装 gitlab-runner

时间:2021-05-12 20:54:12   收藏:0   阅读:71

gitlab-runner

一、安装

安装 gitlab runner 文档参考地址

1、下载exe执行文件

我这里是 win64

https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-windows-amd64.exe

2、创建 gitlab-runner 目录,并进入目录

cd gitlab-runner

3、将上面下载的 gitlab-runner-windows-amd64.exe 放到 gitlab-runner 目录

# 当然不改也可以,这里改名是为了后面执行命令方便
改名成:gitlab-runner.exe

注意后续使用 .\gitlab-runner.exe 执行的命令都需要使用管理员身份运行
否则会被拒绝

4、安装 gitlab-runner

使用系统账号安装gitlab-runner

.\gitlab-runner.exe install

使用指定账户安装gitlab-runner

.\gitlab-runner.exe install --user your-username --password your-password

二、注册 runner

registering runners 文档参考地址

1、注册一个gitlab-runner

注册的 gitlab-runner 分为共享runner和特定runner
共享runner,所有gitalb项目都可用
特定runner,只对指定项目生效

这里我们注册特定runner

.\gitlab-runner.exe register

注册时候需要填写该runner关联的url和token,以及runner的描述和标签tags,还有runner执行时候的脚本类型
.gitlab-ci.yml 中执行任务中的tags,指定要运行的runner
技术分享图片

url 和 token 在 gitlab 项目 ---> 设置 ---> CI/CD ---> Setup a specific Runner manually 获取
技术分享图片

回到 gitlab 页面,刷新即可看到注册的 runner
技术分享图片

三、构建

1、注册好后,在项目中添加 .gitlab-ci.yml 文件

在里面定义gitlab-runner所要执行的逻辑:

2、使用shell executor,构建项目时候,项目将会被克隆到以下目录:

<working-directory>/builds/<short-token>/<concurrent-id>/<namespace>/<project-name>

例如

D:\gitrunner\builds\58820ada\0\web-secure\webapp

项目的caches被存储到

<working-directory>/cache/<namespace>/<project-name>

变量解释:

<working-directory>:runner当前执行的目录或者使用--working-directory指定的目录
<short-token>:runner的token前8位
<concurrent-id>:一个唯一的number,用于区别job,从0开始
<namespace>:项目拥有者的名称
<project-name>:项目名

四、gitlab-runner 常用命令

注意使用 .\gitlab-runner.exe 执行的命令都需要使用管理员身份运行
否则会被拒绝

安装

.\gitlab-runner.exe install

注册

.\gitlab-runner.exe register

启动

.\gitlab-runner.exe start

停止

.\gitlab-runner.exe stop

更新

1、.\gitlab-runner.exe stop
2、下载新版的gitlab-runner程序,替换掉当前的gitlab-runner.exe
3、.\gitlab-runner.exe start

卸载

.\gitlab-runner.exe stop
.\gitlab-runner.exe uninstall
cd ..
rmdir /s gitlab-runner

查看runner状态

.\gitlab-runner.exe status

查看runner列表

.\gitlab-runner.exe list

原文:https://www.cnblogs.com/linjunfu/p/14760750.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!