Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
GitHub Docs

Passing information between jobs

You can define outputs to pass information from one job to another.

Defining and using job outputs

  1. Open the workflow file containing the job you want to get outputs from.

  2. Use thejobs.<job_id>.outputs syntax to define the outputs for the job. For example, the following job defines theoutput1 andoutput2 outputs, which are mapped to the results ofstep1 andstep2 respectively:

    jobs:job1:runs-on:ubuntu-latestoutputs:output1:${{steps.step1.outputs.test}}output2:${{steps.step2.outputs.test}}steps:-id:step1run:echo"test=hello">>"$GITHUB_OUTPUT"-id:step2run:echo"test=world">>"$GITHUB_OUTPUT"
  3. In a separate job where you want to access those outputs, use thejobs.<job_id>.needs syntax to make it dependent on the original job. For example, the following job checks thatjob1 is complete before running:

    jobs:# Assume job1 is defined as abovejob2:runs-on:ubuntu-latestneeds:job1
  4. To access the outputs in the dependent job, use theneeds.<job_id>.outputs.<output_name> syntax. For example, the following job accesses theoutput1 andoutput2 outputs defined injob1:

    jobs:# Assume job1 is defined as abovejob2:runs-on:ubuntu-latestneeds:job1steps:-env:OUTPUT1:${{needs.job1.outputs.output1}}OUTPUT2:${{needs.job1.outputs.output2}}run:echo"$OUTPUT1 $OUTPUT2"

Next steps

To learn more about job outputs and theneeds context, see the following sections ofWorkflow syntax for GitHub Actions:


[8]ページ先頭

©2009-2025 Movatter.jp