问题描述
我有一个与我的项目相关联的跑步者,以避免并发构建.GitLab 在开始新的管道之前处理完整的管道?
I have one runner associated with my project to avoid concurrent build. GitLab to process the complete pipeline before start a new one?
并发设置为 = 1(运行器的配置文件)
concurrent is set to = 1 (config file of the runner)
before_script:
- echo %CI_COMMIT_SHA%
- echo %CI_PROJECT_DIR%
stages:
- createPBLs
- build
- package
create PBLs:
stage: createPBLs
script:
- md "C:HierBauen\%CI_COMMIT_SHA%"
- xcopy /y /s "C:/Bauen" "C:/HierBauen/%CI_COMMIT_SHA%"
- xcopy /y /s "%CI_PROJECT_DIR%" "C:HierBauen\%CI_COMMIT_SHA%"
- cd "C:HierBauen\%CI_COMMIT_SHA%"
- ./run_orcascript.cmd
only:
- tags
- master
build:
stage: build
script:
- cd "C:HierBauen\%CI_COMMIT_SHA%"
- ./run_pbc.cmd
only:
- tags
except:
- master
build_master:
stage: build
script:
- cd "C:HierBauen\%CI_COMMIT_SHA%"
- ./run_pbcm.cmd
only:
- master
package:
stage: package
script:
- cd "C:HierBauen\%CI_COMMIT_SHA%"
- ./cpfiles.cmd
artifacts:
expire_in: 1 week
paths:
- GitLab-Build
name: "%CI_COMMIT_REF_NAME%"
only:
- tags
- master
很遗憾,较早启动的管道受到新启动管道的干扰.结果,构建最终有缺陷......
Unfortunately, the earlier started pipeline is disturbed by a new started pipeline. As a result, the build is flawed at the end ...
编辑新的配置文件:
before_script:
- echo %CI_BUILD_REF%
- echo %CI_PROJECT_DIR%
- xcopy /y /s "C:/Bauen" "%CI_PROJECT_DIR%"
stages:
- createPBLs
- build
- package
create PBLs:
stage: createPBLs
script:
- ./run_orcascript.cmd
only:
- tags
- master
build:
stage: build
script:
- ./run_pbc.cmd
only:
- tags
except:
- master
build_master:
stage: build
script:
- ./run_pbcm.cmd
only:
- master
package:
stage: package
script:
- ./cpfiles.cmd
artifacts:
expire_in: 1 week
name: "%CI_COMMIT_REF_NAME%"
paths:
- GitLab-Build
only:
- tags
- master
推荐答案
目前没有这个办法,有一个开放问题 目前在 GitLab 上.
Currently there is no way for this, and there is an open issue at the moment on GitLab.
您可以做的是在您的 gitlab-runner config.toml
文件中添加 limit = 1
,这将强制 gitlab-runner 只接受一项工作一次.
What you can do instead is to add limit = 1
in your gitlab-runner config.toml
file, which would enforce the gitlab-runner to only accept one job at a time.
我看到你没有在你的阶段之间传递工件,但是如果你的 build
阶段依赖于 createPBLs
阶段中的任何东西,你可以使用artifacts 和 dependencies 在阶段之间传递数据.
I see that you are not passing artifacts between your stages, but if your build
stage, depended on anything in the createPBLs
stage, you can usea combination ofartifacts and dependencies to pass data between stages.
例如:
before_script:
- echo %CI_COMMIT_SHA%
- echo %CI_PROJECT_DIR%
stages:
- createPBLs
- build
- package
create PBLs:
stage: createPBLs
script:
- md "C:HierBauen\%CI_COMMIT_SHA%"
- xcopy /y /s "C:/Bauen" "C:/HierBauen/%CI_COMMIT_SHA%"
- xcopy /y /s "%CI_PROJECT_DIR%" "C:HierBauen\%CI_COMMIT_SHA%"
- cd "C:HierBauen\%CI_COMMIT_SHA%"
- ./run_orcascript.cmd
artifacts:
name: createPBLS_%CI_COMMIT_SHA%
untracked: true
expire_in: 1 day
only:
- tags
- master
build:
stage: build
script:
- cd "C:HierBauen\%CI_COMMIT_SHA%"
- ./run_pbc.cmd
dependencies:
- createPBLs
artifacts:
name: build_%CI_COMMIT_SHA%
untracked: true
expire_in: 1 day
only:
- tags
except:
- master
build_master:
stage: build
script:
- cd "C:HierBauen\%CI_COMMIT_SHA%"
- ./run_pbcm.cmd
dependencies:
- createPBLs
artifacts:
name: build_%CI_COMMIT_SHA%
untracked: true
expire_in: 1 day
only:
- master
package:
stage: package
script:
- cd "C:HierBauen\%CI_COMMIT_SHA%"
- ./cpfiles.cmd
dependencies:
- build_master
artifacts:
expire_in: 1 week
paths:
- GitLab-Build
name: "%CI_COMMIT_REF_NAME%"
only:
- tags
- master
这篇关于如何强制 GitLab 在开始新的管道之前运行完整的管道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!