1

I have a Concourse job that pulls a repo into a docker image and then executes a command on it, now I need to execute a script that comes form the docker image and after it is done execute a command inside the repo, something like this:

run:
  dir: my-repo-resource
  path: /get-git-context.sh && ./gradlew
  args:
    - build

get-git-context.sh is the script coming from my docker image and .gradlew is the standard gradlew inside my repo with the build param, I am getting the following error with this approach:

./gradlew: no such file or directory

Meaning the job cd'd into / when executing the first command, executing only one command works just fine. I've also tried adding two run sections:

run:
  path: /get-git-context.sh
run:
  dir: my-repo-resource
  path: ./gradlew
  args:
  - build

But only the second part is executed, what is the correct way to concat these two commands?

1 Answers1

0

We usually solve this by wrapping the logic in a shell script and setting the path: /bin/bash with corresponding args (path to the script).

run:
  path: /bin/sh
  args:
    - my-repo_resource/some-ci-folder/build_script.sh

The other option would be to define two tasks and pass the resources through the job's workspace, but we usually do more steps than just two and this would result in complex pipelines:

plan:
  - task: task1
    config:
    ...
      outputs:
        - name: taskOutput
      run:
        path: /get-git-context.sh

  - task: task2
    config:
      inputs:
   ## directory defined in task1
        - name: taskOutput 
      run:
        path: ./gradlew
        args:
         - build
briadeus
  • 550
  • 1
  • 6
  • 13