nerdexam
Microsoft

GH-200 · Question #93

Which of the following commands will set the $FOO environment variable within a script, so that it may be used in subsequent workflow job steps?

The correct answer is B. run: echo "FOO=bar" >> $GITHUB_ENV. The $GITHUB_ENV environment variable is used to set environment variables that persist across steps in a workflow job. By echoing FOO=bar into $GITHUB_ENV, the variable FOO will be available in subsequent steps within the same job. Variables set in GITHUB_ENV apply only to the…

Author and Maintain Workflows

Question

Which of the following commands will set the $FOO environment variable within a script, so that it may be used in subsequent workflow job steps?

Options

  • Arun: echo "::set-env name=FOO::bar"
  • Brun: echo "FOO=bar" >> $GITHUB_ENV
  • Crun: echo ${{ $FOO=bar }}
  • Drun: export FOO=bar

How the community answered

(66 responses)
  • A
    5% (3)
  • B
    83% (55)
  • C
    9% (6)
  • D
    3% (2)

Explanation

The $GITHUB_ENV environment variable is used to set environment variables that persist across steps in a workflow job. By echoing FOO=bar into $GITHUB_ENV, the variable FOO will be available in subsequent steps within the same job. Variables set in GITHUB_ENV apply only to the current job. echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV https://github.com/orgs/community/discussions/56849

Topics

#environment variables#workflow syntax#step communication#GitHub Actions

Community Discussion

No community discussion yet for this question.

Full GH-200 Practice