Can not pass git resource to put method

754 views Asked by At

I am trying to get a project from git and pass it to next Put method to run a script. But the git resource is not available to the next put method. Not sure if I am missing some basic things, but being novice to concourse CI-CD thing, not able to figure out exact issue. Here is my concourse pipeline:

    ---
resource_types:
- name: ssh
  type: docker-image
  source:
    repository: quay.io/henry40408/concourse-ssh-resource

resources:
- name: rdt-blr-oc-1
  type: ssh
  source:
    host: 10.xx.xx.xx
    user: user1
    password: password1
- name: commit-etc
  type: git
  icon: gitlab
  source:
    uri: https://gitlab.com/etc.git
    username: ((ci_user))
    password: ((ci_user_password))
    branch: master

jobs:
  - name: run_file_to_remote_host
    serial: true
    public: true
    plan:
      - get: commit-etc
        trigger: false
        inputs: commit-etc
      - put: rdt-blr-oc-1
        params: 
          interpreter: /bin/sh
          path:
          inputs:
            - name: commit-etc
          outputs: 
            - name: commit-etc
          script: |
            hostname;
            HOSTNAME=`hostname`
            echo "Create Unique directory. "
            ls commit-vcode-etc // This directory is not available as failed to find this directory.
1

There are 1 answers

0
Sapphire On

Looking at your pipeline and description, it doesn't look like the put action is what best serves what you're trying the do. A put would push a given resource, in the case of a git resource, it would make a commit. However, you're trying to run a script to list the contents of the commit-etc resource.

To achieve this, you would need to run this as a task step (https://concourse-ci.org/tasks.html) that takes the commit-etc resource as an input. For example:

    jobs:
    - name: run_file_to_remote_host
      serial: true
      public: true
      plan:
        - get: commit-etc
          trigger: false
        - task: rdt-blr-oc-1
          config:
          platform: linux
          image: my-image #the image you'll use the run the script
          inputs:
          - name: commit-etc
          run:
            path: /bin/sh
            args:
            - |
              hostname;
              HOSTNAME=`hostname`
              echo "Create Unique directory. "
              ls commit-etc // This directory is not available as failed to find this directory.

This takes the resource retrieved from the get step and runs the outlined script. This resource is helpful for getting to grips with Concourse fundamentals and how everything fits together: https://concoursetutorial.com