简体   繁体   English

什么是gitlab跑步者

[英]What is gitlab runner

I think I'm fundamentally missing something. 我想我从根本上错过了一些东西。 I'm new to CI/CD and trying to set up my first pipeline ever with gitlab. 我是CI / CD的新手,并试图用gitlab设置我的第一个管道。

The project is a pre-existing PHP project. 该项目是一个预先存在的PHP项目。

I don't want to clean it up just yet, at the moment I've pushed the whole thing into a docker container and it's running fine talking to google cloud's mysql databases etc as it should locally and also on a remote google cloud testing VM. 我还不想清理它,此刻我已经将整个东西推入了一个docker容器中,它正好与google cloud的mysql数据库等交谈,因为它应该在本地以及远程google云测试VM 。 The dream is to be able to push to the development branch, and then merge the dev banch into the test branch which then TRIGGERS automated tests (easy part), and also causes the remote test VM (hosted on google cloud), to PULL the newest changes, rebuild the image from the latest docker file (or pull the latest image from gitlab image register)... and then rebuild the container with the newest image. 我们的梦想是能够推动开发分支,然后将dev banch合并到测试分支中,然后TRIGGERS自动化测试(简单部分),并且还导致远程测试VM(托管在谷歌云上),推出最新更改,从最新的docker文件重建图像(或从gitlab图像寄存器中提取最新图像)...然后使用最新图像重建容器。

I'm playing around with gitlab's runner but I'm not understanding what it's actually for, despite looking through almost all the online content for it. 我正在玩gitlab的跑步者,但我不了解它的实际情况,尽管几乎查看了所有的在线内容。 Do I just install it in the google cloud VM, and then when I push to gitlab from my development machine.. the repo will 'signal' the runner (which is running on the VM, to execute a bunch of scripts (which might include git pull on the newest changes?). 我只是将它安装在谷歌云虚拟机中,然后当我从我的开发机器推送到gitlab时...回购将“发出信号”跑步者(在VM上运行,执行一堆脚本(可能包括git拉最新的变化?)。

Because I already pre-package my app into a container locally (and push the image to the image registry) do I need to use docker as my executor on the runner? 因为我已经将我的应用程序预先打包到本地容器中(并将图像推送到图像注册表)我是否需要使用docker作为我在跑步者身上的执行者? or can i just use shell and shell the commands in? 或者我可以使用shell和shell命令吗?

What am I missing? 我错过了什么?

TLDR and extra: TLDR和额外:

Questions: 问题:

  1. What is runner actually for, where is it meant to be installed? 什么是跑步者实际上,它意味着安装在哪里?
    Does it care which directory it is run in? 是否关心它运行在哪个目录中?
    If it doesn't care which directory it's run, where does it execute it's script commands? 如果它不关心它运行的目录,它在哪里执行它的脚本命令? At root? 在根?

  2. If I am locally building my own images and uploading them to gitlab's registry, 如果我在本地构建自己的图像并将其上传到gitlab的注册表,

Do I need to set my executor to docker? 我需要将执行者设置为docker吗? Shouldn't I just set it to shell, pull the image, and build it? 我不应该只是将它设置为shell,拉动图像,并构建它? (Assuming the runner is runing on the remote VM). (假设跑步者在远程VM上运行)。

What is runner actually for? 什么是赛跑者?

You have your project along with a .gitlab-ci.yml file. 您的项目以及.gitlab-ci.yml文件。 .gitlab-ci.yml defines what stages your CI/CD pipeline has and what to do in each stage. .gitlab-ci.yml定义了CI / CD管道的哪些阶段以及每个阶段的操作。 This typically consists of a build,test,deploy stages. 这通常包括构建,测试和部署阶段。 Within each stage you can define multiple job. 在每个阶段中,您可以定义多个作业。 For example in build stage you may have 3 jobs to build on debian, centos and windows (in GitLab glossary build:debian , build:centos , build:windows ). 例如,在构建阶段,你可以在debian,centos和windows上构建3个作业(在GitLab词汇表build:debianbuild:centosbuild:windows )。 A GitLab runner clones the project read the gitlab-ci.yaml file and do what he is instructed to do. GitLab运行器克隆项目读取gitlab-ci.yaml文件并执行他指示要执行的操作。 So basically GitLab runner is a Golang process that executes some instructed tasks. 所以基本上GitLab runner是一个执行一些指令任务的Golang进程。

where is it meant to be installed? 它意味着要安装在哪里?

You can install a runner in your desired environment listed here. 您可以在此处列出的所需环境中安装跑步者。 https://docs.gitlab.com/runner/install/ or you can use a shared runner that is already installed on GitLab's infrastructure. https://docs.gitlab.com/runner/install/或者您可以使用已安装在GitLab基础架构上的共享运行器。

Does it care which directory it is run in? 是否关心它运行在哪个目录中?

Yes. 是。 Every task executed by runner is relativly to CI_PROJECT_DIR defined in https://gitlab.com/help/ci/variables/README . 通过执行亚军每一个任务就是要relativly CI_PROJECT_DIR定义https://gitlab.com/help/ci/variables/README But you can alter this behaviour. 但是你可以改变这种行为。

where does it execute it's script commands? 它在哪里执行它的脚本命令? At root? 在根?

Do I need to set my executor to docker? 我需要将执行者设置为docker吗? Shouldn't I just set it to shell, pull the image, and build it? 我不应该只是将它设置为shell,拉动图像,并构建它?

A runner can have mutiple executors such as docker, shell, virtualbox etc but docker being the most common one. 跑步者可以有多个执行器,如docker,shell,virtualbox等,但docker是最常见的。 If you use docker as the executor you can pull any image from docker hub or your configured registry and you can do loads of stff with docker images. 如果您使用docker作为执行程序,您可以从docker hub或配置的注册表中提取任何图像,并且可以使用docker镜像执行大量的stff。 In a docker environment normally you run them as the root user. 在docker环境中,通常以root用户身份运行它们。 https://docs.gitlab.com/runner/executors/README.html https://docs.gitlab.com/runner/executors/README.html

看gitlab访问日志,跑者不断轮询服务器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM