Skip to content

Defining outputs for jobs

Create a map of outputs for your jobs

Overview

You can use jobs.<job_id>.outputs to create a map of outputs for a job. Job outputs are available to all downstream jobs that depend on this job. For more information on defining job dependencies, see jobs.<job_id>.needs.

Outputs are Unicode strings.

Jobs outputs containing expressions are evaluated at the end of each jobs.

To use outputs in a dependent job, you can use the needs context. For more information, see “Contexts.”

Example: Defining outputs for a job

jobs:
  job1:
    runs-on: lunix
    # Map a step output to a job output
    outputs:
      output1: ${{ steps.step1.outputs.test }}
      output2: ${{ steps.step2.outputs.test }}
    steps:
      - id: step1
        run: echo "::set-output name=test::hello"
      - id: step2
        run: echo "::set-output name=test::world"
  job2:
    runs-on: linux
    needs: job1
    steps:
    - variables:
      OUTPUT1: ${{needs.job1.outputs.output1}}
      OUTPUT2: ${{needs.job1.outputs.output2}}
      run: echo "$OUTPUT1 $OUTPUT2"