Skip to Content
Xeonr Developer Docs
Pipelines

Pass outputs between steps and jobs

Write a value in one step and read it in a later step of the same job, or in a job that needs this one.

Available in repositories branchd reads pipeline files for. It is switching repositories on one at a time: until yours is, it keeps running its .forge-ci.yaml or .xeonr-ci.yaml. See What is available.

.branchd/pipelines/ci.yaml
# .branchd/pipelines/ci.yaml
# A step writes name=value lines to $BRANCHD_OUTPUT. A later step of the
# same job reads them as steps.<id>.outputs.<name>; a job that needs this
# one reads the job's outputs as needs.<job>.outputs.<name>.
name: CI
on: push
jobs:
  version:
    image: alpine:3
    outputs:
      version: ${{ steps.v.outputs.version }}
      channel: ${{ steps.v.outputs.channel }}
    steps:
      - id: v
        run: |
          echo "version=1.4.$CI_PIPELINE_IID" >> "$BRANCHD_OUTPUT"
          echo "channel=${{ branch == 'main' && 'stable' || 'beta' }}" >> "$BRANCHD_OUTPUT"
      - name: Use it in the same job
        run: echo "building ${{ steps.v.outputs.version }}"
  package:
    needs: [version]
    image: alpine:3
    env:
      VERSION: ${{ needs.version.outputs.version }}
    steps:
      - run: echo "packaging $VERSION for ${{ needs.version.outputs.channel }}"
  • Writing. A step writes name=value lines to the file named by $BRANCHD_OUTPUT. Each step gets a fresh one.
  • In the same job. A step with an id: makes its outputs readable by later steps as ${{ steps.<id>.outputs.<name> }}.
  • To other jobs. The job's outputs: map names to values, usually a step's output. A job that needs it reads ${{ needs.<job>.outputs.<name> }} in run:, env:, with: and image:.
  • One line each. An output is one line; a value whose fixed text has a line break is refused.
  • Known only while the job runs. A job that reads another's outputs must need it, directly. An if: may read them: a step's if: reads an earlier step's (if: steps.changes.outputs.api == 'true'), decided when the step's turn comes, and a job's if: reads a needed job's (if: needs.release.outputs.released == 'true'), decided when its needs have run; a job whose if: is then false is skipped, with the jobs that need it. Only ==, !=, contains, startsWith, endsWith, an output on its own (true when not empty), !, && and || read an output in an if:; an output never set reads as ''. See Expressions.
  • Names. Two step ids, job ids or output names that differ only in - and _ are refused: they would name the same variable.
  • Where they reach. A run: job's outputs reach the run: steps and env: of the jobs that need it. To feed a typed step's with: or a job's image:, the value must come from a typed step's job, as in Build and push an image.
  • A matrix job has no outputs.

Not yet available (script outputs to images): a run: job's outputs reaching another job's image: or a typed step's with:. Only a typed step's outputs reach those.