[英]How to force GitLab to run a complete pipeline before starting a new one?
I have one runner associated with my project to avoid concurrent build.我有一个与我的项目相关联的跑步者,以避免并发构建。 GitLab to process the complete pipeline before start a new one?
GitLab 在开始新管道之前处理完整的管道?
concurrent is set to = 1 (config file of the runner)并发设置为= 1(跑步者的配置文件)
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...
结果,构建在最后是有缺陷的......
EDIT new config file:编辑新的配置文件:
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
Currently there is no way for this, and there is an open issue at the moment on GitLab.目前没有办法做到这一点,目前 GitLab 上有一个未解决的问题。
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.你可以做的是在你的 gitlab-runner
config.toml
文件中添加limit = 1
,这将强制 gitlab-runner 一次只接受一项工作。
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 use a combination of artifacts and dependencies to pass data between stages.我看到您没有在阶段之间传递工件,但是如果您的
build
阶段依赖于createPBLs
阶段中的任何内容,您可以使用工件和依赖项的组合在阶段之间传递数据。
For example:例如:
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
Use the resource_group
feature, which provides a way to group jobs which need the same mutex wrapped around them.使用
resource_group
功能,它提供了一种方法来对需要相同互斥锁的作业进行分组。 Out of the box, resource_group
s don't provide this pipeline-level mutexing (concurrency prevention), however, using the process mode option, specifically setting it to "oldest first", does.开箱即用,
resource_group
不提供这种管道级互斥(并发预防),但是,使用进程模式选项,特别是将其设置为“最早的优先”,可以。 The docs further state that: 文档进一步指出:
To change the process mode of a resource group, you must use the API and send a request to edit an existing resource group by specifying the process_mode:
要更改资源组的进程模式,您必须使用 API 并通过指定 process_mode 发送编辑现有资源组的请求:
unordered oldest_first newest_first
Also mentioned here: https://stackoverflow.com/a/74286510/532621此处还提到: https ://stackoverflow.com/a/74286510/532621
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.