{"meta":{"title":"Passing information between jobs","intro":"You can define outputs to pass information from one job to another.","product":"GitHub Actions","breadcrumbs":[{"href":"/en/actions","title":"GitHub Actions"},{"href":"/en/actions/how-tos","title":"How-tos"},{"href":"/en/actions/how-tos/write-workflows","title":"Write workflows"},{"href":"/en/actions/how-tos/write-workflows/choose-what-workflows-do","title":"Choose what workflows do"},{"href":"/en/actions/how-tos/write-workflows/choose-what-workflows-do/pass-job-outputs","title":"Pass job outputs"}],"documentType":"article"},"body":"# Passing information between jobs\n\nYou can define outputs to pass information from one job to another.\n\n## Defining and using job outputs\n\n1. Open the workflow file containing the job you want to get outputs from.\n\n2. Use the `jobs.<job_id>.outputs` syntax to define the outputs for the job. For example, the following job defines the `output1` and `output2` outputs, which are mapped to the results of `step1` and `step2` respectively:\n\n   ```yaml\n   jobs:\n     job1:\n       runs-on: ubuntu-latest\n       outputs:\n         output1: ${{ steps.step1.outputs.test }}\n         output2: ${{ steps.step2.outputs.test }}\n       steps:\n         - id: step1\n           run: echo \"test=hello\" >> \"$GITHUB_OUTPUT\"\n         - id: step2\n           run: echo \"test=world\" >> \"$GITHUB_OUTPUT\"\n   ```\n\n3. In a separate job where you want to access those outputs, use the `jobs.<job_id>.needs` syntax to make it dependent on the original job. For example, the following job checks that `job1` is complete before running:\n\n   ```yaml\n   jobs:\n     # Assume job1 is defined as above\n     job2:\n       runs-on: ubuntu-latest\n       needs: job1\n   ```\n\n4. To access the outputs in the dependent job, use the `needs.<job_id>.outputs.<output_name>` syntax. For example, the following job accesses the `output1` and `output2` outputs defined in `job1`:\n\n   ```yaml\n   jobs:\n     # Assume job1 is defined as above\n     job2:\n       runs-on: ubuntu-latest\n       needs: job1\n       steps:\n         - env:\n             OUTPUT1: ${{needs.job1.outputs.output1}}\n             OUTPUT2: ${{needs.job1.outputs.output2}}\n           run: echo \"$OUTPUT1 $OUTPUT2\"\n   ```\n\n## Next steps\n\nTo learn more about job outputs and the `needs` context, see the following sections of [Workflow syntax for GitHub Actions](/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idoutputs):\n\n* [`jobs.<job_id>.outputs`](/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idoutputs)\n* [`jobs.<job_id>.needs`](/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idneeds)\n\nTo learn more about passing job outputs from one workflow to another, see the following section of [Reuse workflows](/en/actions/how-tos/reuse-automations/reuse-workflows):\n\n* [Using outputs from a reusable workflow](/en/actions/how-tos/reuse-automations/reuse-workflows#using-outputs-from-a-reusable-workflow)"}