title: Concourse: how to pass job's output to a different job
body: <p>It's not clear for me from <a href="https://concourse-ci.org/running-tasks.html" rel="noreferrer">the documentation</a> if it's even possible to pass one job's output to the another job (not from task to task, but from job to job).</p>
  
  <p>I don't know if conceptually I'm doing the right thing, maybe it should be modeled differently in Concourse, but what I'm trying to achieve is having pipeline for Java project split into several granular jobs, which can be executed in parallel, and triggered independently if I need to re-run some job.</p>
  
  <p>How I see the pipeline:</p>
  
  <ol>
  <li>First job:
  
  <ul>
  <li>pulls the code from github repo</li>
  <li>builds the project with maven</li>
  <li>deploys artifacts to the maven repository (<code>mvn deploy</code>)</li>
  <li>updates <code>SNAPSHOT</code> versions of the Maven project submodules</li>
  <li>copies artifacts (jar files) to the output directory (<code>output</code> of the <code>task</code>)</li>
  </ul></li>
  <li>Second job:
  
  <ul>
  <li>picks up <code>jar</code>'s from the <code>output</code></li>
  <li>builds docker containers for all of them (in parallel)</li>
  </ul></li>
  <li>Pipeline goes on</li>
  </ol>
  
  <p>I was unable to pass the <code>output</code> from job 1 to job 2.
  Also, I am curious if any changes I introduce to the original git repo resource will be present in the next job (from job 1 to job 2).</p>
  
  <p>So the questions are:</p>
  
  <ol>
  <li>What is a proper way to pass build state from job to job (I know, jobs might get scheduled on different nodes, and definitely in different containers)?</li>
  <li>Is it necessary to store the state in a resource (say, S3/git)?</li>
  <li>Is the Concourse stateless by design (in this context)?</li>
  <li>Where's the best place to get more info? I've tried the manual, it's just not that detailed.</li>
  </ol>
  
  <p>What I've found so far:</p>
  
  <ol>
  <li><code>output</code>s are not passed from job to job</li>
  <li>Any changes to the resource (<code>put</code> to the github repo) are fetched in the next job, but changes in working copy are not</li>
  </ol>
  
  <p>Minimal example (it fails if commented lines are uncommented with error: <code>missing inputs: gist-upd, gist-out</code>):</p>
  
  <pre><code>---
  resources:
    - name: gist
      type: git
      source:
        uri: "git@bitbucket.org:snippets/foo/bar.git"
        branch: master
        private_key: {{private_git_key}}
  
  jobs:
    - name: update
      plan:
        - get: gist
          trigger: true
  
        - task: update-gist
          config:
            platform: linux
            image_resource:
              type: docker-image
              source: {repository: concourse/bosh-cli}
  
            inputs:
              - name: gist
  
            outputs:
              - name: gist-upd
              - name: gist-out
  
            run:
              path: sh
              args:
                - -exc
                - |
                  git config --global user.email "nobody@concourse.ci"
                  git config --global user.name "Concourse"
                  git clone gist gist-upd
                  cd gist-upd
                  echo `date` &gt; test
                  git commit -am "upd"
                  cd ../gist
                  echo "foo" &gt; test
                  cd ../gist-out
                  echo "out" &gt; test
  
        - put: gist
          params: {repository: gist-upd}
  
    - name: fetch-updated
      plan:
        - get: gist
          passed: [update]
          trigger: true
  
        - task: check-gist
          config:
            platform: linux
            image_resource:
              type: docker-image
              source: {repository: alpine}
  
            inputs:
              - name: gist
              #- name: gist-upd
              #- name: gist-out
  
            run:
              path: sh
              args:
                - -exc
                - |
                  ls -l gist
                  cat gist/test
                  #ls -l gist-upd
                  #cat gist-upd/test
                  #ls -l gist-out
                  #cat gist-out/test
  </code></pre>