gitlab - GitLab 动态并行运行作业
问题描述
我有一个项目,它在遵循特定约定的文件夹中生成 go main 文件。问题是当有代码推送时,我需要在 Gitlab CI 管道中并行构建这些项目,而我无法硬编码它们,.gitlab-ci.yml
因为它们是动态生成的。我需要并行构建这些 go 项目,并且如果所有单个项目构建成功,则需要通过构建阶段。有人可以让我知道在 Gitlab 中是否可行。
解决方案
现在也可以使用子管道功能。您可以使用 YTT 为子管道生成 YAML 配置文件 - 但只要您提供有效的 YAML 文件,任何生成方法都可以使用。
.gitlab-ci.yml
generate-config:
stage: build
script: ytt -f config-template.yml -f config-template-values.yml --data-value-yaml services="[${SERVICES}]" > generated-config.yml # with SERVICES=service1,service2
artifacts:
paths:
- generated-config.yml
child-pipeline:
stage: test
trigger:
include:
- artifact: generated-config.yml
job: generate-config
配置模板.yml
#@ load("@ytt:data", "data")
stages:
- test
#@ for service in data.values.services:
#@yaml/text-templated-strings
(@= service @)-test:
stage: test
script:
- #@ "test " + service
#@ end
配置模板值.yml
#@data/values
---
services: []
推荐阅读
- c - 连接到 MQTT 代理时出现 SSL 错误
- html - 如何在容器中居中 div 元素
- oracle-apex - 在按需 ajax 进程 (PL/SQL) 中向会话提交页面项目值
- javascript - 调用另一个函数时如何禁用函数?
- css - 隐藏特定 wordpress 类别中所有帖子的 CSS 按钮
- php - 使用 symfony 中的参数执行 sql 请求时出现语法错误?
- google-bigquery - 将旧版 SQL 转换为标准 SQL - 增强型电子商务
- python-3.x - 如何使用帧单元制作 TIME 字幕(.srt、.smi 等)
- c# - 无法从另一个脚本实例化预制件
- facebook-graph-api - 获取我自己的 Instagram 帖子所需的 Graph API 权限