2

I'm using Concourse as my CI Pipeline and my pipeline basically builds an rpm out of some files from a git resource and then places the rpm in another git repo. when i first created the repo and ran the concourse pipeline it put the rpm in the repo without any issues. Subsequent Puts however have failed with the following git error.

> 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.

Here is my 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}}
user2051904
  • 75
  • 1
  • 9

1 Answers1

1

It looks like you are always making the "first commit" to outputbuild, and attempting to force push over it.

Force push is currently an unmerged pull-request to the git-resource.

If you wanted to do this the proper git way, you would have to make sure the place you are pushing from (i.e. outputbuild-dir) is actually based on the original git history of outputbuild (i.e. you are only adding commits, not changing history)

For example:

---
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}}
materialdesigner
  • 1,492
  • 10
  • 13