什么是gitlabRunner [英] What is gitlab runner

查看:59
本文介绍了什么是gitlabRunner的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为我从根本上缺少一些东西.我是CI/CD的新手,正在尝试使用gitlab建立我的第一个管道.

I think I'm fundamentally missing something. I'm new to CI/CD and trying to set up my first pipeline ever with gitlab.

该项目是一个预先存在的PHP项目.

The project is a pre-existing PHP project.

我现在还不想清理它,此刻我已经将整个东西都推送到了docker容器中,并且它可以很好地与google cloud的mysql数据库进行通信,因为它应该在本地以及在远程google上进行通信云测试虚拟机.梦想是能够推送到开发分支,然后将开发包合并到测试分支,然后TRIGGERS自动化测试(简单的部分),并且还使远程测试VM(托管在Google云上)拉到最新更改,请从最新的docker文件中重建映像(或从gitlab映像寄存器中提取最新的映像)...,然后使用最新的映像重建容器.

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. 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.

我正在与gitlab的跑步者玩耍,尽管浏览了几乎所有在线内容,但我仍不明白它的实际用途.我是否只是将其安装在Google Cloud VM中,然后当我从开发计算机上推送到gitlab时.回购协议会发出信号"运行器(在VM上运行,以执行一堆脚本(可能包括git可以获取最新的更改吗?).

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. 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?).

因为我已经将我的应用程序预先本地打包到一个容器中(并将图像推送到图像注册表),我是否需要使用docker作为运行程序上的执行程序?还是我可以只使用shell并在其中运行命令?

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? or can i just use shell and shell the commands in?

我想念什么?

TLDR及其他:

问题:

  1. 跑步者的真正目的是什么,打算在哪里安装?
    它关心在哪个目录中运行吗?
    如果它不在乎运行哪个目录,它在哪里执行脚本命令?根源?

  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?

如果我在本地构建自己的图像并将其上传到gitlab的注册表中,

If I am locally building my own images and uploading them to gitlab's registry,

我需要将执行程序设置为docker吗?我不应该将其设置为shell,提取图像并进行构建吗?(假设运行程序在远程VM上运行).

Do I need to set my executor to docker? Shouldn't I just set it to shell, pull the image, and build it? (Assuming the runner is runing on the remote VM).

推荐答案

跑步者实际上是干什么的?

What is runner actually for?

您拥有一个项目以及一个 .gitlab-ci.yml 文件. .gitlab-ci.yml 定义您的CI/CD管道具有哪些阶段以及在每个阶段做什么.这通常包括构建,测试,部署阶段.在每个阶段中,您可以定义多个作业.例如,在构建阶段,您可能要在debian,centos和Windows上构建3个作业(在GitLab词汇表中, build:debian build:centos build:windows).一个GitLab运行器克隆了项目,读取了gitlab-ci.yaml文件,并按照指示执行操作.因此,基本上,GitLab运行程序是一个执行某些指示性任务的 Golang 进程.

You have your project along with a .gitlab-ci.yml file. .gitlab-ci.yml defines what stages your CI/CD pipeline has and what to do in each stage. 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). A GitLab runner clones the project read the gitlab-ci.yaml file and do what he is instructed to do. So basically GitLab runner is a Golang process that executes some instructed tasks.

它应该在哪里安装?

where is it meant to be installed?

您可以在此处列出的所需环境中安装流道. https://docs.gitlab.com/runner/install/或者您可以使用已经安装在GitLab基础结构上的共享运行器.

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.

它关心它在哪个目录中运行吗?

Does it care which directory it is run in?

是的.跑步者执行的每个任务都相对地符合 https://gitlab中定义的 CI_PROJECT_DIR .com/help/ci/variables/README .但是您可以更改此行为.

Yes. Every task executed by runner is relativly to CI_PROJECT_DIR defined in https://gitlab.com/help/ci/variables/README. But you can alter this behaviour.

它在哪里执行脚本命令?根本吗?

where does it execute it's script commands? At root?

我需要将执行程序设置为docker吗?我不应该将其设置为外壳,拉动图像并进行构建吗?

Do I need to set my executor to docker? Shouldn't I just set it to shell, pull the image, and build it?

跑步者可以有多个执行程序,例如docker,shell,virtualbox等,但docker是最常见的执行程序.如果您将docker用作执行程序,则可以从docker hub或配置的注册表中提取任何映像,并且可以使用docker映像加载stff.在docker环境中,通常您以root用户身份运行它们. https://docs.gitlab.com/runner/executors/README.html

A runner can have mutiple executors such as docker, shell, virtualbox etc but docker being the most common one. 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. In a docker environment normally you run them as the root user. https://docs.gitlab.com/runner/executors/README.html

这篇关于什么是gitlabRunner的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆