打包流水线:单一配置

我们将从最简单的情况开始,即我们只需要构建 1 个配置,并且该配置可以在当前的 CI 机器上构建。

正如我们在介绍不同的服务器二进制存储库时所描述的,默认情况下,包构建将仅使用 develop 存储库,该存储库被认为是开发人员和 CI 作业的稳定存储库。

此流水线从干净的状态开始,缓存中没有包,并且仅启用了 develop 存储库。

在此配置下,CI 作业可以执行

$ cd ai
$ conan create . --build="missing:ai/*"
...
ai/1.1.0: SUPER BETTER Artificial Intelligence for aliens (Release)!
ai/1.1.0: Intelligence level=50

请注意,在某些情况下,--build="missing:ai/*" 可能不是完全必需的,但在其他情况下可以节省时间。例如,如果开发人员仅对存储库 README 进行了一些更改,而根本没有更改版本号,Conan 将不会生成新的 recipe revision,并将其检测为无操作,从而避免不必要地从源代码重新构建二进制文件。

如果我们在单配置场景中并且它已成功构建,对于这种情况,我们不需要促销,直接将构建的包上传到 products 存储库就足够了,在那里 products pipeline 将在之后拾取它。

# We don't want to disrupt developers or CI, upload to products
$ conan remote enable products
$ conan upload "ai*" -r=products -c
$ conan remote disable products

由于缓存最初是空的,所有 ai 包都将是在此流水线中构建的包。

digraph repositories { node [fillcolor="lightskyblue", style=filled, shape=box] rankdir="LR"; subgraph cluster_0 { label="Packages server"; style=filled; color=lightgrey; subgraph cluster_1 { label = "packages\n repository" shape = "box"; style=filled; color=lightblue; "packages" [style=invis]; } subgraph cluster_2 { label = "products\n repository" shape = "box"; style=filled; color=lightblue; "products" [style=invis]; "ai/1.1.0\n (single config)"; } subgraph cluster_3 { rankdir="BT"; shape = "box"; label = "develop repository"; color=lightblue; rankdir="BT"; node [fillcolor="lightskyblue", style=filled, shape=box] "game/1.0" -> "engine/1.0" -> "ai/1.0" -> "mathlib/1.0"; "engine/1.0" -> "graphics/1.0" -> "mathlib/1.0"; "mapviewer/1.0" -> "graphics/1.0"; "game/1.0" [fillcolor="lightgreen"]; "mapviewer/1.0" [fillcolor="lightgreen"]; } { edge[style=invis]; "packages" -> "products" -> "game/1.0" ; rankdir="BT"; } } }

这是一个非常简单的情况,现在让我们进入一个更实际的情况:需要构建多个配置。