我在 Concourse 中设置了管道,其中包含一些构建 Docker 映像的作业。构建后,我将图像标签推送到 git 存储库。问题是当构建同时结束时,一个作业推送到 git,而另一个只是拉动,当第二个作业尝试推送到 git 时,它会出错。
error: failed to push some refs to 'git@github.com:*****/*****'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
那么有什么办法可以防止并发推送呢?
到目前为止,我已经尝试过申请serial
和serial_groups
工作。它有帮助,但是所有的工作都排队了,因为我们有很多构建。
如果其他作业锁定了它,我希望作业在对 git 执行操作之前同时运行并暂停。
resources:
- name: backend-helm-repo
type: git
source:
branch: master
paths:
- helm
uri: git@github.com:******/******
-...
jobs:
-...
- name: some-hidden-api-build
serial: true
serial_groups:
- build-alone
plan:
- get: some-hidden-api-repo
trigger: true
- get: golang
- task: build-image
file: somefile.yaml
- put: some-hidden-api-image
- get: backend-helm-repo
- task: update-helm-tag
config:
platform: linux
image_resource:
type: registry-image
source:
repository: mikefarah/yq
tag: latest
run:
path: /bin/sh
args:
- -xce
- "file manipulations && git commit"
inputs:
- name: some-hidden-api-repo
- name: backend-helm-repo
outputs:
- name: backend-helm-tag-bump
- put: backend-helm-repo
params:
repository: backend-helm-tag-bump
- put: some-hidden-api-status
params:
commit: some-hidden-api-repo
state: success
- name: some-other-build
serial: true
serial_groups:
- build-alone
plan:
- get: some-other-repo
trigger: true
- get: golang
- task: build-image
file: somefile.yaml
- put: some-other-image
- get: backend-helm-repo
- task: update-helm-tag
config:
platform: linux
image_resource:
type: registry-image
source:
repository: mikefarah/yq
tag: latest
run:
path: /bin/sh
args:
- -xce
- "file manipulations && git commit"
inputs:
- name: some-other-repo
- name: backend-helm-repo
outputs:
- name: backend-helm-tag-bump
- put: backend-helm-repo
params:
repository: backend-helm-tag-bump
- put: some-other-status
params:
commit: some-other-repo
state: success
-...
因此,如果作业同时完成映像构建并并行执行 git commit,则一个推送比第二个更快,第二个会中断。
有人可以帮忙吗?