gpt4 book ai didi

gitlab-ci - 探索平行矩阵

转载 作者:行者123 更新时间:2023-12-05 03:50:00 44 4
gpt4 key购买 nike

这似乎是对 GitLab 13.3 中新的并行矩阵功能的误用 (https://docs.gitlab.com/ee/ci/yaml/#parallel-matrix-jobs)

我有一组服务的并行作业集合:build (docker image), test, release, 删除....并创建代码库,以便每个并行服务位于单独的子目录中。

这样我就可以有一个通用的模板:

variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE/$LOCATION

.build-template:
script:
- docker build --tag $IMAGE_NAME:$CI_PIPELINE_ID-$CI_COMMIT_REF_SLUG --tag $IMAGE_NAME:latest $LOCATION
stage: build
when: manual

然后是多个构建作业:

build-alpha:
extends: .build-template
variables:
LOCATION: alpha

build-beta:
extends: .build-template
variables:
LOCATION: beta

....并根据需要重复。

然后我可以为 testreleasedelete 作业做同样的事情:一个通用模板,它只需要一个变量区分服务。

救援矩阵?

在我看来

variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE/$NOTEBOOK

build-services:
parallel:
matrix:
- LOCATION: alpha
- LOCATION: beta
script:
- docker build --tag $IMAGE_NAME:$CI_PIPELINE_ID-$CI_COMMIT_REF_SLUG --tag $IMAGE_NAME:latest $LOCATION
stage: build
when: manual

将是此矩阵形式的理想候选者....但显然矩阵需要两个变量.

有没有人找到解决这个多并行作业问题的好方法?

最佳答案

would be an ideal candidate for this matrix form.... but apparently matrix requires two variables.

不再是了。

参见 GitLab 13.5 (2020 年 10 月)

Allow one dimensional parallel matrices

Previously, the parallel: matrix keyword, which runs a matrix of jobs in parallel, only accepted two-dimensional matrix arrays. This was limiting if you wanted to specify your own array of values for certain jobs.

In this release, you now have more flexibility to run your jobs the way that works best for your development workflow.
You can run a parallel matrix of jobs in a one-dimensional array, making your pipeline configuration much simpler. Thanks Turo Soisenniemi for your amazing contribution!

Here’s a basic example of this in practice that will run 3 test jobs for different versions of Node.js, but you can apply this approach to your specific use cases and easily add or remove jobs in your pipeline as well:

https://about.gitlab.com/images/13_5/simple-parallel-matrices-example.png -- One dimensional matrices example

See Documentation and Issue.


还有GitLab 13.10 (2021 年 3 月)

Use 'parallel: matrix' with trigger jobs

You can use the parallel: matrix keywords to run jobs multiple times in parallel, using different variable values for each instance of the job.

Unfortunately, you could not use it with trigger jobs.

In this release, we’ve expanded the parallel matrix feature to support trigger jobs as well, so you can now run multiple downstream pipelines (child or multi-project pipelines) in parallel using different variables value for each downstream pipeline.
This lets you configure CI/CD pipelines that are faster and more flexible.

https://about.gitlab.com/images/13_10/parallel.png -- Use 'parallel: matrix' with trigger jobs

See Documentation and Issue.

关于gitlab-ci - 探索平行矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63689772/

44 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com