了解 Gitlab CI 标签 [英] Understanding Gitlab CI tags

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

问题描述

我已经阅读了文档,一些文章,你可能会说我笨,但这是我第一次使用这样的概念.

I've read documentation, some articles and you might call me dumb, but this is my first time working with a concept like this.

  • 我已经注册了带有testing"标签的跑步者
  • 在 gitlab 中创建标签测试"
  • 将此跑步者与特定项目绑定
  • 我还添加了相同的标签,例如在我的本地仓库中测试".

但是运行我的作业究竟是如何依赖这些标签的?所有这些操作都需要吗?如果我将新代码推送到 repo,就我测试而言,*.yml 文件无论如何都会执行.

BUT how exactly is running my jobs dependent on those tags? Are all these operations necessary? If I push new code to repo, *.yml file is executed anyway as far as I tested.

如果我只想在提交中定义版本时运行构建呢?

IDK...

   git commit --tags "v. 2.0" -m "this is version 2.0" (probably not right)

但当然应该是通用的,所以我不必总是告诉,使用哪个标签来触发跑步者,但例如让他识别数值.

But of course it should be universal, so I don't have to always tell, which tag to use to trigger the runner, but for example let him recognize numeric values.

如您所见,我很困惑...如果您能详细说明标签的工作原理,以便我能够理解这个概念,我将不胜感激.

推荐答案

GitLab CI 的标签和 Git 的标签是两个不同的概念.

Tags for GitLab CI and tags for Git are two different concepts.

当你编写 .gitlab-ci.yml 时,你可以使用 testing 标签指定一些作业.如果与此标签关联的跑步者可用,它将接手.

When you write your .gitlab-ci.yml, you can specify some jobs with the tag testing. If a runner with this tag associated is available, it will pickup the job.

在 Git 中,在您的存储库中,标签用于标记特定的提交.它通常用于标记一个版本.

In Git, within your repository, tags are used to mark a specific commit. It is often used to tag a version.

当您在 GitLab CI 中使用标签(在 Git 中)启动管道时,这两个概念可能会混淆.在您的 .gitlab-ci.yml 中,您可以使用 tags 指定部分 only.

The two concepts can be mixed up when you use tags (in Git) to start your pipeline in GitLab CI. In your .gitlab-ci.yml, you can specify the section only with tags.

请参阅 GitLab 文档了解标签only.

一个例子是当你用 git 推送一个标签时:

An example is when you push a tag with git:

$ git tag -a 1.0.0 -m "1.0.0"
$ git push origin 1.0.0

.gitlab-ci.yml 中的工作是这样的:

compile:
    stage: build
    only: [tags]
    script:
        - echo Working...
    tags: [testing]    

将开始使用带有 testing 标签的运行器.

would start using a runner with the testing tag.

据我了解,您的步骤中缺少的是为您的跑步者指定标签 testing.为此,请在 GitLab 中进入您的项目.旁边的Wiki,点击设置.转到 CI/CD 管道,您就有了跑步者.在其 Guid 旁边,单击钢笔图标.在下一页可以修改标签.

By my understanding, what is missing in your steps is to specify the tag testing to your runner. To do this, go in GitLab into your project. Next to Wiki, click on Settings. Go to CI/CD Pipelines and there you have your runner(s). Next to its Guid, click on the pen icon. On next page the tags can be modified.

这篇关于了解 Gitlab CI 标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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