Skip to main content

Job outputs

Definition

You can specify a set of outputs that you want to pass to subsequent jobs and then access those values from your needs context.

A map of outputs for a job.

jobs.<jobs_id>.outputs

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.

Job outputs are strings, and job outputs containing expressions are evaluated on the runner at the end of each job. Outputs containing secrets are redacted on the runner and not sent to GitHub Actions.

To use job outputs in a dependent job, you can use the needs context.

To use job outputs in a dependent job, you can use the needs context.

Worflow example

info

See documentation for more information: GitHub Actions documentation.

caution

The set-output command is deprecated and will be disabled on 31st May 2023.
Please upgrade to using environment files or job outputs instead.

jobs:
job1:
runs-on: ubuntu-latest

steps:
- id: step1
run: echo "test=hello" >> $GITHUB_OUTPUT
- id: step2
run: echo "test=hello" >> $GITHUB_OUTPUT

# Map a step output to a job output
outputs:
output1: ${{ steps.step1.outputs.test }}
output2: ${{ steps.step2.outputs.test }}

job2:
runs-on: ubuntu-latest
needs: job1

steps:
- run: echo ${{needs.job1.outputs.output1}} ${{needs.job1.outputs.output2}}