concourse

Concourse CI, get and put a git-resource


I'm trying to use a git-resource to get, modify and push a file but it isn't work, can someone help me?

The two resources point to the same git repository and the goal is to add a file in the repository. I can't understand where I'm wrong, concourse output is green but the repository doesn't have the new file

This is the job:

jobs:
- name: myjob
  plan:
  - get: input-repo
  - get: output-repo

  - task: simpletask
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: ubuntu
      run:
        path: sh
        args:
          - -exc
          - |
            cat a_file > output-repo/another_file
      inputs:
      - name: input-repo
      - name: output-repo

  - put: input-repo
    params: { repository: output-repo }

Solution

  • you should not need two different resources for this. What you want to do is to get (git clone) the repo, modify it, git commit it and then put (git push) it.

    So you want something like this.

    jobs:
    - name: myjob
      plan:
      - get: repo
    
      - task: simpletask
        config:
          platform: linux
          image_resource:
            type: docker-image
            source:
              repository: ubuntu
          run:
            path: sh
            args:
              - -exc
              - |
                cp -r repo changed-repo
                cat a_file > changed-repo/another_file
                git add .
                git commit -m "message"
    
          inputs:
          - name: repo
    
      - put: repo
        params: { repository: changed-repo }