How to pass output of task to put?


#1

For example:

jobs:

- name: jenkins-integration-demo
  plan:
  - get: trigger-concourse
    trigger: true

  - task: show-new-build
    config:
      platform: linux
      image_resource:
        type: docker-image
        source: {repository: busybox}
      inputs:
      - name: trigger-concourse
      run:
        path: my_task.sh

  - put: triggered-by-concourse
    params:
      buildParams: msg=Triggered-by-concourse

In this job, I do a task, then do a put. Now I want to take some info and use the info as buildParams for put, how to archive that?


#2

Hello, I see you are learning Concourse, welcome!. You will go faster if you start with a tutorial: https://concoursetutorial.com/.

This will allow you to understand Concourse, instead of going from one roadblock to another :slight_smile:


#3

I have done the tutorial. I learned how to pass data from a task to next task. But I haven’t seen how to pass data from task to put. Also I don’t see how to pass data from a job to next job.


#4

Are you sure you’ve done the whole tutorial? This part specifically answers your question :wink:

Its essentially the same as passing data from task to task. All outputs of previous tasks are implicitly mounted to put containers.

The only way to pass data from job to job is by putting/getting to/from resources. This part of the tutorial covers it.


#5

Yes, I have done both of them. The tutorial shows how to pass data via files. But my question is how to pass data via like variables. For example, with my sample in the question, say the task generates a message, e.g. “message generated by task 1”, and I want to pass the message to buildParams of put. Is it possible?

From the tutorial, looks like Concourse can like only copy a task’s output files to following task’s input folder, is that true?


#6

No. You can’t pass variables between steps in a job. The way I usually get around that is to write the variables into a file, passing that along, then sourcing the file at the start of the next task. For passing them to a put I don’t think it’s possible.