ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

在 Linux 上手动安装 GitLab运行器(GitLab Runner)

2022-06-01 13:32:50  阅读:248  来源: 互联网

标签:gitlab Runner GitLab runner https Linux docker Enter


 

runner是一个任务执行器,我们可以在任意一个可访问的地方安装runner,并注册到我们的gitlab系统中,这样我们就能使用gitlab ci/cd功能进行持续集成构建项目了

如果您无法使用deb/rpm 存储库安装 GitLab Runner,或者您的 GNU/Linux 操作系统不在受支持的操作系统中,您可以使用以下方法之一手动安装它,作为最后的手段。

如果你想使用Docker 执行器,你必须 在使用 GitLab Runner 之前 安装 Docker 。

 

①安装gitlab-runnner rpm包

在这里选择适合你系统的gitlab runner包https://gitlab-runner-downloads.s3.amazonaws.com/latest/index.html

curl -LJO https://gitlab-runner-downloads.s3.amazonaws.com/latest/rpm/gitlab-runner_amd64.rpm

②安装rpm 包

rpm -i gitlab-runner_amd64.rpm

③注册Runner

Ⅰ、Run the following command

gitlab-runner register

Ⅱ、Enter your GitLab instance URL:(GitLab实例地址,上面GitLab的地址)

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

Ⅲ、Enter the token you obtained to register the Runner(输入注册Runner的token):

Please enter the gitlab-ci token for this runner
hUCad4cXYPEKTt

 

 

 

token所在地方:

​ 1、登入GitLabhttp://115.30.149.35:8888

​ 2、点击工具刀

 

 

​ 3、Overview->Runners

 

 

红色框里面即为token。

 

Ⅳ、Enter a description for the Runner, you can change this later in GitLab’s UI(添加Runner描述):

Please enter the gitlab-ci description for this runner
my-runner

Ⅴ、Add a Tag

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

Ⅵ、Enter the Runner executor:

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

 

 

 

④刷新GitLab页面

可看到注册的Runner。

 

 总结:

 gitLab 运行器可以直接在linux安装,也可以使用docker方式安装,下面是docker

1 安装

#创建目录放置配置
mkdir -p /data/gitlab-runner/config
 
#启动docker容器,如果镜像不存在会自动拉取
docker run -itd --restart=always --name gitlab-runner \
> -v /data/gitlab-runner/config:/etc/gitlab-runner \
> -v /var/run/docker.sock:/var/run/docker.sock  gitlab/gitlab-runner:latest

 

  2 注册

        先进入容器,在进行注册

root@buntu:docker exec -it gitlab-runner bash
root@3d5e7569adce:/# gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=27 revision=c6e7e194 version=14.8.2
Running in system-mode.
 
Enter the GitLab instance URL (for example, https://gitlab.com/):
https://gitlab.yourdomin.com.cn/ #你的gitlab服务域名
Enter the registration token:
ciA6DkobmzZVYLF-xxxx #在gitlab->管理区域->概述->Runners的注册令牌
Enter a description for the runner:
[3d5e7569adce]: runner for demo #随便写
Enter tags for the runner (comma-separated):
irunner #在yaml文件的tags中使用,必须以字母开头
Enter optional maintenance note for the runner:
 
Registering runner... succeeded                     runner=ciA6Dkob
Enter an executor: docker-ssh+machine, custom, docker, docker-ssh, shell, virtualbox, parallels, ssh, docker+machine, kubernetes:
docker
Enter the default Docker image (for example, ruby:2.7):
docker:20.10.7
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!

 

鸣谢:

 https://blog.csdn.net/lenkty/article/details/123281204

https://www.cnblogs.com/roluodev/p/12251472.html

https://www.cnblogs.com/baoruizhe/p/16198309.html

https://blog.csdn.net/qq_42183414/article/details/123145369

https://docs.gitlab.com/runner/configuration/

https://docs.gitlab.com/ee/install/docker.html

 

标签:gitlab,Runner,GitLab,runner,https,Linux,docker,Enter
来源: https://www.cnblogs.com/yakniu/p/16333951.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有