【问题标题】:Gitlab runner starting another job before one before it finishesGitlab 跑步者在完成之前开始另一项工作
【发布时间】:2020-04-24 12:25:05
【问题描述】:

我为单个项目配置了一个 gitlab 运行器。我看到的问题是跑步者不会等到前一个作业完成,而是在与前一个作业相同的目录中进行结帐并踩踏所有内容。我有一个工作已经在运行,然后另一个开发提交,因此另一个工作开始了。为什么我不能将管道配置为不运行,以免损坏已经运行的工作区?

这是两个作业的日志(唯一的区别是时间戳)

[0K] Running with gitlab-runner 12.6.0 (ac8e767a)
[0K]  on gitlab.xxxx.com rz8RmGp4
[0K] section_start:1578357551:prepare_executor
[0K] Using Docker executor with image my-image-build ...
[0K] Using locally found image version due to if-not-present pull policy
[0K] Using docker image sha256:xxxxxxxxxx for my-image-build ...
[0;msection_end:1578357553:prepare_executor
[0Ksection_start:1578357553:prepare_script
[0K] Running on runner-rz8RmGp4-project-23-concurrent-0 via gitlab.xxxx.com...
section_end:1578357554:prepare_script
[0K] section_start:1578357554:get_sources
[0K[32;1mFetching changes with git depth set to 50...[0;m
Initialized empty Git repository in /builds/my-project/.git/
<proceeds to checkout and stomp over the already running runner>

我看到的主要问题是他们都签出到Initialized empty Git repository in /builds/my-project/.git/ 的同一目录,这导致了问题。

【问题讨论】:

    标签: gitlab gitlab-ci gitlab-ci-runner


    【解决方案1】:

    您可以使用resource_group 来阻止作业并行运行。

    例如

    Job 1:
      stage: My Stage
      resource_group: stage-wedge
      ...
    Job 2:
      stage: My Stage
      resource_group: stage-wedge
      ...
    

    在上面的示例中,作业 2 将在作业 1 完成后运行。

    【讨论】:

      【解决方案2】:

      同一阶段的作业并行执行。 如果您需要它是连续的,您可以为每个作业添加一个阶段。

      查看文档 https://docs.gitlab.com/ee/ci/yaml/#stages

      如果运行多个管道,您可能需要配置 gitlab-runner 选项:限制/并发

      https://docs.gitlab.com/runner/configuration/advanced-configuration.html

      【讨论】:

      • 我明白这一点。我的问题是我有两个单独的提交,它们在两个不同的分支上触发了管道构建。出于某种原因,第二个触发器继续运行并检出与前一个触发器位于同一目录中的源代码。我想限制后续管道触发器运行,直到第一个完成或工作目录被两个进程使用。
      • 哦,对不起,我错了,我确实更新了我的答案,包括通过在 gitlab-runner 中设置限制/并发设置的建议。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-09
      • 1970-01-01
      • 2021-08-10
      • 2021-07-07
      • 2018-05-22
      • 2016-01-20
      • 1970-01-01
      相关资源
      最近更新 更多