执行单个Gitlab CI管道的多个跑步者

发布于 2025-02-05 20:27:49 字数 268 浏览 4 评论 0原文

我有一个gitlab CI配置为在部署每个服务器之前仅在3个不同的服务器上构建和部署代码,并仅在部署每个服务器之前进行较小的更改。在部署之前,我根据服务器部署了一些文件,并将其推到CI管道的同一仓库中。 为此,我想使用3个不同的跑步者来运行以构建和部署代码到每个服务器,但找不到该方法。 我可以在多个跑步者上并行运行(使用并行矩阵)在管道中运行的每个作业,但是作业运行的顺序(即首先在所有跑步者上执行1个作业),在部署作业之前,更改将不会持续。

有什么方法可以触发多个跑步者执行同一作业?还是他们的解决方法。

I have a gitlab CI configured to build and deploy code to 3 different servers with just minor changes before deploying each. Before deploying, I edit some files based on the server they are being deployed and push to the same repo from the CI pipeline.
For this purpose, I want to use 3 different runners to run in order to build and deploy the code to each server but couldn't find how to do it.
I can make each job in pipeline to run in parallel (using parallel matrix) on multiple runners, but the order in which the jobs run (i.e. execute 1 job first on all runners), the changes will not persist till the deploy job.

Is there a way I can trigger multiple runners to execute same job? or is their a workaround.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清引 2025-02-12 20:27:50

定义唯一 tags 对于您的每个跑步者代码>,deploy-rhel8deploy-solaris)。

创建一个“ nofollow noreferrer”>模板作业和三个工作(每个目标系统)(一个目标系统)扩展模板作业。然后定义所需的标签对于这三个工作中的每一个。

享受成功,每个作业都在自己的特定跑步者上运行,部署正确的软件版本。

Define unique tags for each of your runners (ex. deploy-win11, deploy-rhel8, deploy-solaris).

Create a template job and three jobs (each for one target system) that extends the template job. Then define required tags for each of these three jobs.

Enjoy success, where each job runs on its own specific runner, deploying the correct version of your software.

南笙 2025-02-12 20:27:50

我不确定我完全理解这个问题,但是我认为您缺少阶段

您可以在.gitlab-ci.yml中定义这样的阶段
(您可以根据需要命名):

stages:
- build
- test
- deploy

这样,管道将等到所有构建作业完成后将其运行test作业。

现在,您必须指定工作应执行的阶段:

build_job_1:
  variables:
    NODE_OPTIONS: --max_old_space_size=8192
    GIT_CLEAN_FLAGS: none
  stage: build
  tags:
    - runner1

build_job_2:
  variables:
    NODE_OPTIONS: --max_old_space_size=4096
  stage: build
  tags:
    - runner2

I'm not sure I completely understand the question, but I think you're missing stages.

You can define your stages like this in your .gitlab-ci.yml
(you can name them however you want):

stages:
- build
- test
- deploy

This way, the pipeline will wait until all build jobs finish before it will run the test jobs.

Now, you have to specify in which stage a job should execute:

build_job_1:
  variables:
    NODE_OPTIONS: --max_old_space_size=8192
    GIT_CLEAN_FLAGS: none
  stage: build
  tags:
    - runner1

build_job_2:
  variables:
    NODE_OPTIONS: --max_old_space_size=4096
  stage: build
  tags:
    - runner2
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文