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

查看:599
本文介绍了了解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.

  • 我已经为跑步者注册了测试"标签
  • 在gitlab中创建标签测试"
  • 将该奔跑者与特定项目绑定在一起
  • 我还添加了相同的标签,例如在我的本地仓库中进行测试".

但是取决于这些标签,我的工作究竟有多准确?所有这些操作都是必要的吗?如果我将新代码推送到仓库中,则* .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.

当您使用标签(在Git中)在GitLab CI中启动管道时,这两个概念可能会混淆.在.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文档例如,当您使用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 it's Guid, click on the pen icon. On next page the tags can be modified.

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

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