网站公共模板是什么意思,网站搜索优化找哪家,黄页号码查询,网络推广员有前途吗原理
Gitlab-Runner是一个非常强大的CI/CD工具。它可以帮助我们自动化执行各种任务#xff0c;如构建、测试和部署等。Gitlab-Runner和Gitlab通过API通信#xff0c;接收作业并提交到执行队列#xff0c;Gitlab-Runner从队列中获取作业#xff0c;并允许在不同环境下进行作…原理
Gitlab-Runner是一个非常强大的CI/CD工具。它可以帮助我们自动化执行各种任务如构建、测试和部署等。Gitlab-Runner和Gitlab通过API通信接收作业并提交到执行队列Gitlab-Runner从队列中获取作业并允许在不同环境下进行作业。
安装和注册
安装
yum install gitlab-runner注册
首先获取gitlab的token以供gitlab-runner注册时使用Gitlab runner 分 3 类注册在不同位置runner权限也不同 Share Runner推荐使用所有 group 的所有 project 都能使用 Group Runner: 该 Group 内的所有 Project 都可以使用 Specific Runner一个 Project 独享的 Runner其他项目默认不能使用
token位置gitlab → group/project → settings → cicd → runners
注册runner根据提示依次配置以下参数
gitlab-runner register Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
https\://****** Please enter the gitlab-ci token for this runner:
VyaV8t****** Please enter the gitlab-ci description for this runner:
test runner Please enter the gitlab-ci tags for this runner (comma separated):
test Whether to run untagged builds \[true/false]: \[false]:
true Whether to lock the Runner to current project \[true/false]: \[true]:
true Registering runner... succeeded runnerqtWs5Db6 Please enter the executor: shell, ssh, dockermachine, docker, docker-ssh, parallels, virtualbox, docker-sshmachine, docker:
shell Runner registered successfully. Feel free to start it, but if its running already the config should be automatically reloaded!
第一个参数输入gitlab-url第二个参数输入token第三个参数输入描述第四个参数输入标签tag第五个参数选择执行的命令之类的可以根据自身需求选择。
*executor执行器
在注册runner的最后一步提示了选择所需的执行器不同执行器对ci的影响很大简单介绍一下runner的执行器
执行器作业运行说明shell默认执行器意味着所有job都在runner上运行dockerdocker容器job将在docker容器运行docker-windowsWindows Docker 容器docker-sshDocker 容器使用 SSH 连接ssh远程SSHparallelsParallels VM使用 SSH 连接一种虚机virtualboxVirtualBox VM但使用 SSH 连接一种虚机dockermachine类似docker但使用自动缩放的 Docker 机器docker-sshmachine类似docker-ssh但使用自动缩放的 Docker 机器kubernetesKubernetes pods
.gitlab-ci.yml配置
举个简单的例子主要为了展示.gitlab-ci.yml如何让gitlab与runner联动
# This file is a template, and might need editing before it works on your project. stages: - hello - build sayhello: tags: - test stage: hello script: - echo hello world compile: tags: - test stage: build script: - bash build.sh
以上配置文件设置了hello和build两个步骤tags指定用哪个runner运行ci。git接收到代码push根据ci规则建立Pipelines向runner发起jobrunner接收job开始根据设置的步骤依此执行。 第一步输出 hello world
第二步执行项目中的build.sh脚本