简介
GitLab Runner是用于运行作业并将结果发回给GitLab的开源项目。它与GitLab CI一起使用,GitLab CI是GitLab中包含的开源持续集成服务,用于协调作业。
官方页面:https://docs.gitlab.com/runner/
安装
GitLab Runner可以在GNU / Linux,macOS,FreeBSD和Windows上安装和使用。您可以使用Docker安装它,手动下载二进制文件或使用GitLab提供的rpm / deb软件包的存储库。
使用官方GitLab存储库安装GitLab Runner
1、添加GitLab的官方存储库:
# For Debian/Ubuntu/Mint curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | bash # For RHEL/CentOS/Fedora curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | bash
2、安装最新版本的GitLab Runner,或跳到下一步安装特定版本:
# For Debian/Ubuntu/Mint apt-get install gitlab-runner # For RHEL/CentOS/Fedora yum install gitlab-runner
3、要安装特定版本的GitLab Runner:
# for DEB based systems apt-cache madison gitlab-runner apt-get install gitlab-runner=10.0.0 # for RPM based systems yum list gitlab-runner --showduplicates | sort -r yum install gitlab-runner-10.0.0-1
4、更新版本
# For Debian/Ubuntu/Mint sudo apt-get update sudo apt-get install gitlab-runner # For RHEL/CentOS/Fedora sudo yum update sudo yum install gitlab-runner
注册
注册Runner是将Runner与GitLab实例绑定在一起的过程,在GitLab选择注册哪种Runner,GitLab中有:项目runner,组runner,共享runner(只能管理员注册),在项目或组及共享的CI/CD设置中获取相关的URL及token。关于Runner的区别详细参考资料:https://docs.gitlab.com/ce/ci/runners/
Linux中注册Runner
我这里选择注册的是共享Runner,管理员中CI/CD中获取
1、运行以下命令:
gitlab-runner register
2、输入你的GitLab实例URL:
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com ) http://192.168.1.235/
3、输入您获得的注册Runner的令牌:
Please enter the gitlab-ci token for this runner VKUPz_SKryy_jQ8R3Uxy
4、输入跑步者的描述,你可以稍后在GitLab的用户界面中进行更改:
Please enter the gitlab-ci description for this runner Deploy-share
5、输入与Runner关联的标签,稍后可以在GitLab的用户界面中进行更改:
Please enter the gitlab-ci tags for this runner (comma separated): Deploy
6、输入Runner执行者:
Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell: Shell
7、如果您选择Docker作为您的执行程序,则会要求您为默认图像用于未定义的项目.gitlab-ci.yml:
Please enter the Docker image (eg. ruby:2.1): alpine:latest
