nerdexam
Microsoft

GH-200 · Question #92

Which scopes are available to define custom environment variables within a workflow file? (Choose three.)

The correct answer is A. the entire workflow, by using env at the top level of the workflow file E. the contents of a job within a workflow, by using jobs.env F. a specific step within a job, by using jobs..steps[*].env. GitHub Actions supports three scopes for defining environment variables via the 'env' key. (A) Workflow-level: placing 'env' at the top level of the YAML file makes variables available to all jobs and steps in the workflow. (E) Job-level: placing 'env' under a specific job defini

Author and Maintain Workflows

Question

Which scopes are available to define custom environment variables within a workflow file? (Choose three.)

Options

  • Athe entire workflow, by using env at the top level of the workflow file
  • Ball jobs being run on a single Actions runner, by using runner.env at the top of the workflow file
  • Cthe entire stage, by using env at the top of the defined build stage
  • Dwithin the run attribute of a job step
  • Ethe contents of a job within a workflow, by using jobs.env
  • Fa specific step within a job, by using jobs..steps[*].env

How the community answered

(25 responses)
  • A
    88% (22)
  • B
    4% (1)
  • D
    8% (2)

Explanation

GitHub Actions supports three scopes for defining environment variables via the 'env' key. (A) Workflow-level: placing 'env' at the top level of the YAML file makes variables available to all jobs and steps in the workflow. (E) Job-level: placing 'env' under a specific job definition (jobs.<job_id>.env) scopes variables to all steps within that job only. (F) Step-level: placing 'env' inside a specific step (jobs.<job_id>.steps[*].env) restricts the variable to that single step. Option B is wrong - there is no 'runner.env' construct in workflow YAML; runner environment variables are separate. Option C is wrong - GitHub Actions has no concept of 'stages' (that is a GitLab CI term). These three scopes (workflow, job, step) are the complete set of env var scopes in GitHub Actions.

Topics

#Environment Variables#Workflow Syntax#GitHub Actions#Workflow Scope

Community Discussion

No community discussion yet for this question.

Full GH-200 Practice