2

我使用 Concourse 作为我的 CI 管道,我的管道基本上从 git 资源中的一些文件构建一个 rpm,然后将 rpm 放在另一个 git 存储库中。当我第一次创建 repo 并运行 concourse 管道时,它将 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}}
4

1 回答 1

1

看起来您总是对 进行“第一次提交” outputbuild,并试图强行推动它。

强制推送当前是对 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}}
于 2016-12-05T18:29:03.083 回答