Concourse GIT 放置到 git 资源时出错

Concourse GIT errors on puts to git resource

我正在使用 Concourse 作为我的 CI 管道,我的管道基本上是从 git 资源中的一些文件构建一个 rpm,然后将 rpm 放在另一个 git 存储库中.当我第一次创建 repo 和 运行 concourse pipeline 时,它​​将 rpm 毫无问题地放入 repo 中。然而,随后的 Put 失败并出现以下 git 错误。

> Identity added: /tmp/git-resource-private-key (/tmp/git-resource-private-key)
To git@github.private.com:private/repo1.git
 ! [rejected]        HEAD -> master (fetch first)
error: failed to push some refs to 'git@github.private.com:username/repo1.git'
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.

这是我的pipeline.yml

---
jobs:
- name: job-build
serial: true
plan:
- get: Inputbuild
trigger: true
- task: <task-name>
config:
  …
  …
  inputs:
  - name: Inputbuild
  outputs:
  - name: outputbuild-dir
  run:
    path: Inputbuild/script.sh
- put: outputbuild
  params: {repository: outputbuild-dir}

resources:
- name: Inputbuild
  type: git
  source:
  uri: git@github.private.com:username/repo.git
  branch: master
  private_key: {{private_github_key}}

- name: outputbuild
  type: git
  source:
  uri: git@github.private.com:username/repo1.git
  branch: master
  private_key: {{private_github_repo1_key}}

看起来你总是在 "first commit" 到 outputbuild,并试图强行推过去。

强制推送目前是未合并的 pull-request 到 git-资源。

如果您想以正确的 git 方式执行此操作,则必须确保您推送的位置(即 outputbuild-dir)实际上是基于原始 git outputbuild 的历史记录(即您只是添加提交,而不是更改历史记录)

例如:

---
jobs:
- name: job-build
  serial: true
  plan:
  - get: Inputbuild
    trigger: true
  - get: outputbuild
  - task: build-artifacts
    config:
    …
    inputs:
    - name: Inputbuild
    - name: outputbuild
    outputs:
    - name: outputbuild-dir
    run:
      path: /bin/bash #Inputbuild/script.sh 
      args:
      - -c
      - |
        #!/bin/bash

        rm outputbuild-dir
        git clone outputbuild outputbuild-dir
        # do stuff with inputbuild
        # cp built artifacts into outputbuild-dir
        cd outputbuild-dir
        git add .
        git commit -m "Update built artifacts"
  - put: outputbuild
    params: {repository: outputbuild-dir}

resources:
- name: Inputbuild
  type: git
  source:
  uri: git@github.private.com:username/repo.git
  branch: master
  private_key: {{private_github_key}}

- name: outputbuild
  type: git
  source:
  uri: git@github.private.com:username/repo1.git
  branch: master
  private_key: {{private_github_repo1_key}}