GitLab Runner
GitLab Runner是一个开源项目,用于运行你的作业(jobs)并将结果发送回GitLab。它与GitLab CI结合使用,GitLab CI是GitLab用于协调jobs的开源持续集成服务。 1. Install Install GitLab Runner using the official GitLab repositories?(首选) 1、添加GitLab的官方仓库: # For RHEL/CentOS/Fedora
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
2、安装最新版本的GitLab Runner sudo yum install gitlab-runner
3、为了安装特定版本 yum list gitlab-runner --showduplicates | sort -r
gitlab-runner-10.0.0-1
4、升级Runner sudo yum update
gitlab-runner
Install GitLab Runner manually on GNU/Linux (手动安装)? # For CentOS or Red Hat Enterprise Linux
-LJO https://gitlab-runner-downloads.s3.amazonaws.com/latest/rpm/gitlab-runner_.rpm
# 例如:
https://s3.amazonaws.com/gitlab-runner-downloads/master/rpm/gitlab-runner_arm.rpm
https://s3.amazonaws.com/gitlab-runner-downloads/master/rpm/gitlab-runner_amd64.rpm
https://s3.amazonaws.com/gitlab-runner-downloads/master/rpm/gitlab-runner_i686.rpm?
下载完以后即可安装 rpm -i gitlab-runner_<arch>.rpm
gitlab-runner_arm.rpm
# 升级:
-Uvh gitlab-runner_arm.rpm?
手动安装 1、下载二进制文件 # Linux x86-64
sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
# Linux x86
/usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-386
/usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-arm
/usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-arm64
2、添加可执行权限 sudo chmod +x /usr/local/bin/gitlab-runner
3、创建GitLab CI用户 sudo useradd --comment 'GitLab Runner' --create-home --shell /bin/bash
4、安装并作为服务运行 sudo gitlab-runner install --user=--working-directory/home/gitlab-runner
sudo gitlab-runner start
sudo gitlab-runner stop
2. Register 一个Runner可以特定于某个项目,也可以在GitLab CI中服务于任何项目。服务于所有项目的Runner称为共享Runner。 理想情况下,不应将GitLab Runner与GitLab安装在同一台机器上。
(PS:怎么理解Shared Runners用的公平队列和Specific Runners用的FIFO队列呢?举个例子: 假设有这个一个队列 Job 1 for Project 1 那么,Shared Runner执行作业的顺序会是146253,而Specific Runner执行作业的顺序是123456 ) Specific Runners 仅针对特定的项目运行,Shared Runners 则可以为每一个启用了“运行shared Runners”的项目执行作业。通过Settings > CI/CD 下进行设置。 如果你是GitLab实例管理员的话,你可以注册一个Shared Runner 1、在admin/runners页面获取shared-Runner token 2、注册Runner,如前所述 3. Executors
GitLab Runner 实现了许多executors,用于在不同场景下运行你的构建。? 3.1. 选择Executor executors支持不同的平台和方法来构建项目 ? Shell executor :Shell是最简单的executor,但是,它需要将构建所需的所有依赖手动安装到安装了Runner的同一台计算机上。 Virtual Machine executor :这种executor使得你可以使用已创建的虚拟机,该虚拟机将被克隆并用于运行你的构建。它提供了两个完整的系统虚拟化选项:VirtualBox和Parallels。如果你想在不同的操作系统上运行构建,它们将非常有用,因为它允许在Windows,Linux,macOS或FreeBSD上创建虚拟机,然后GitLab Runner连接到虚拟机并在其上运行构建。它的用法对于降低基础架构成本也很有用。 Docker executor :使用Docker executor是一个非常不错的选择,因为它提供了一个干净的构建环境,并且具有轻松的依赖关系管理(用于构建项目的所有依赖关系都可以放在Docker镜像中)。Docker executor允许你可以轻松地使用依赖服务(例如MySQL)创建构建环境。 Docker Machine executor :Docker Machine是Docker executor的特殊版本,支持自动伸缩。它像普通的Docker executor一样工作,但具有Docker Machine按需创建的构建主机。 Kubernetes executor :Kubernetes executor允许你使用现有的Kubernetes集群进行构建。executor将调用Kubernetes集群API并为每个GitLab CI作业创建一个新的Pod(带有构建容器和服务容器)。 ? 在与GitLab CI一起使用时,Docker executor将连接到Docker Engine,并使用在.gitlab-ci.yml中设置的预定义镜像在单独的隔离容器中运行每个构建。这样,你可以拥有一个简单且可复制的构建环境。 当与GitLab CI一起使用时,Kubernetes executor将连接到集群中的Kubernetes API,为每个GitLab CI Job创建一个Pod。该Pod至少由一个构建容器,一个辅助容器以及一个用于.gitlab-ci.yml文件定义的每个服务的附加容器组成。? 详细配置请看文档 4. Docs https://docs.gitlab.com/runner/ https://docs.gitlab.com/runner/install/ https://docs.gitlab.com/runner/register/? https://docs.gitlab.com/runner/executors/README.html https://docs.gitlab.com/runner/executors/kubernetes.html https://docs.gitlab.com/ee/ci/runners/? https://docs.gitlab.com/runner/commands/README.html? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |