Gitlab-CI 又名管道依赖项中的上游触发 [英] Upstream triggering in Gitlab-CI aka pipeline dependencies

查看:16
本文介绍了Gitlab-CI 又名管道依赖项中的上游触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法从这样的工具中找到最明显的 CI 功能:在另一个项目的管道完成后运行项目管道.您可以使用 trigger 执行此操作,但仅用于下游触发,如果您有一个项目是 20 个其他项目的核心依赖项,这些项目都需要重建,这与您想要的相反.

I can't seem to find the most obvious CI feature that one ever needs from such a tool: run a project pipeline after another project's pipeline has finished. You can do it with trigger but only for downstream triggering, which is the opposite of what you want in case you have a project that is a core dependency of 20 other projects which all need to be rebuilt.

在这种情况下,您需要能够定义如下内容:

What you need in this case is to be able to define something like:

A 项目:没什么特别的,只是一条普通的管道

Project A: nothing particular, just a normal pipeline

项目 B,依赖"于项目 A:

.gitlab-ci.yml

from_upstream:
  stage: pre
  trigger:
    project: ProjectA

它的作用是在 ProjectA 管道 [成功] 完成时触发 ProjectB 构建.

What it does is trigger ProjectB build whenever a ProjectA pipeline has [successfully] finished.

相反,您必须以类似的方式在 ProjectA 中声明所有数十个下游,这既愚蠢又适得其反,尤其是当 ProjectA 是一个在各处不断重用的核心库时.

Instead you must declare all dozens of downstreams in ProjectA in a similar fasion, which is silly and counter-productive, especially when ProjectA is a core library that gets constantly reused everywhere.

那么,谁能解释一下为什么 GitlabCI 缺少一个在 Bamboo 和 Hudson/Jenkins 中已有数十年的明显功能(即使在 EE 中也不可用)?以及如何使用 Gitlab-CI 做我需要的事情?

So, can someone please explain why GitlabCI is missing an obvious feature (which isn't available even in EE) that has been in Bamboo and Hudson/Jenkins for decades? And how do i do what i need with Gitlab-CI?

更新:似乎上游/下游的概念对某些人来说确实令人困惑,所以澄清一下:upstream Project A 是并且必须始终与 downstream 项目 B 因为关注点分离是一回事,上游维护者不能也不应该知道他们的项目如何在下游使用.

UPDATE: It seems the notion of upstream/downstream is really confusing for some people, so just to clarify: upstream Project A is and must always be decoupled from downstream Project B because separation of concern is a thing and upstream maintainers couldn't and shouldn't possibly have any knowledge on how their project is used downstream.

因此,所需的功能(同样在 Bamboo 和 Jenkins 中已经存在了几十年)是下游管道在上游管道上声明被动触发器,而不是像当前在 Gitlab-CI 中实现的那样使用主动触发器.

So, desired functionality (which, again, exists for decades in Bamboo and Jenkins) is that downstream pipelines declare passive triggers on upstream pipelines, not the other way around with active triggers as it's currently implemented in Gitlab-CI.

推荐答案

只要管道为不同项目中的新标签完成,您就可以触发项目中的管道.此功能是在 12.8 版中引入的.它仅限于新标签,需要付费订阅.

You can trigger a pipeline in your project whenever a pipeline finishes for a new tag in a different project. This feature was introduced in version 12.8. It is limited to new tags and requires a premium subscription.

https://gitlab.com/gitlab-org/gitlab/-/issues/9045

这篇关于Gitlab-CI 又名管道依赖项中的上游触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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