Gitlab CI-启动普通回购协议的共享运行器
我是Gitlab CI的新手.
I'm new to Gitlab CI.
我已经配置了.gitlab-ci.yml文件,并使用CI Lint通过了验证过程.
I have configured .gitlab-ci.yml file, and using CI Lint it has passed the validation process.
基于此文档,我可以看到应该在其中配置特定的运行器一个虚拟机,一个VPS,一个裸机,一个Docker容器甚至是一组容器.
Based on this documentation, I can see a specific runner should be configured on a virtual machine, a VPS, a bare-metal machine, a docker container or even a cluster of containers.
我可以看到gitlab有自己的共享运行器,并且默认情况下启用了 .
And I can see gitlab has its own shared runners and enabled by default.
当我访问管道"页面时,我只能看到蓝色的"管道入门" 按钮,单击该按钮后,我将被重定向到
When I visit the Pipeline page I can only see the blue Get Started with Pipeline button and when clicked I was redirected to this page.
" Gitlab CI-如何启动Shared Runner "表示Gitlab CI仅会为
The "Gitlab CI - How to start Shared Runner" says that Gitlab CI will only run the job for the testing
branch, however, none of my git use branch unless for very specific cases. So
问题是如何在只有一个master
分支的普通(私有)存储库中使用此共享运行器?
The question is how to use this shared runner in my normal (private) repo that has only the single master
branch?
共享运行程序将在 any 分支中运行,因此在master
分支中也将运行(除非您否则进行配置.
Shared runners will run for any branch, so for the master
branch too (unless you configure otherwise).
另外,
- 如果您定义了标签,则可以选择特定的跑步者为您的工作.
- 您可以过滤是否通过
- you can pick-up a specific runner if you define a tag for your job.
- you can filter if the job will be triggered via only and/or
except
directives.
例如,尽管有分支,以下作业将触发任何推送:
For example, following job will trigger for any push, despite the branch:
buildClient:
stage: buildComponents
script:
- echo "Building the client..."
另一方面,此作业仅在推送到develop
分支时才会触发,并且任何具有docker
标记的可用运行器都将对其进行处理:
On the other hand, this job will trigger only for push to the develop
branch and it will be processed by any available runner with the docker
tag:
buildServer:
stage: buildComponents
script:
- echo "Building the server with Docker..."
only:
- develop
tags:
- docker
根据蓝色的管道入门按钮:您需要将.gitlab-ci.yml
文件添加到项目的根目录并将其推送到GitLab.该文件定义了构建管道的 stages 和 jobs .然后,跑步者根据给定的配置选择工作.例如.简单的.gitlab-ci.yml
看起来可能像这样:
According the blue Get Started with Pipeline button: You need to add a .gitlab-ci.yml
file to the root of your project and push it to GitLab. This file defines stages and jobs of your build pipeline. Jobs are then picked-up by runners according the given configuration. E.g. simple .gitlab-ci.yml
can look like this:
image: alpine:latest
stages:
- test
- build
testApp:
stage: test
script: echo "Testing..."
buildApp:
stage: build
script: echo "Building..."
请参见使用.gitlab-ci.yml配置工作在GitLab文档中获取更多详细信息.
See Configuration of your jobs with .gitlab-ci.yml in GitLab documentation for more details.