Skip to content

Setting default values for jobs

Define the default settings that will apply to all jobs in the workflow, or all steps in a job.

Overview

Use defaults to create a map of default settings that will apply to all jobs in the workflow. You can also set default settings that are only available for a job. For more information, see jobs.<job_id>.defaults.

When more than one default setting is defined with the same name, the orchestrator uses the most specific default setting. For example, a default setting defined in a job will override a default setting that has the same name defined in a workflow.

Example: Set the default execution environment

defaults:
  runs-on: linux

Setting default shell and working directory

You can use defaults.run to provide default shell and working-directory options for all run steps in a workflow. You can also set default settings for run that are only available to a job. For more information, see jobs.<job_id>.defaults.run.

When more than one default setting is defined with the same name, the orchestrator uses the most specific default setting. For example, a default setting defined in a job will override a default setting that has the same name defined in a workflow.

Example: Set the default shell and working directory

defaults:
  run:
    shell: bash
    working-directory: ./scripts

Setting default values for a specific job

Use jobs.<job_id>.defaults to create a map of default settings that will apply to all steps in the job. You can also set default settings for the entire workflow. For more information, see defaults.

When more than one default setting is defined with the same name, the orchestrator uses the most specific default setting. For example, a default setting defined in a job will override a default setting that has the same name defined in a workflow.

Setting default shell and working directory for a job

Use jobs.<job_id>.defaults.run to provide default shell and working-directory to all run steps in the job.

You can provide default shell and working-directory options for all run steps in a job. You can also sete default settings for run for the entire workflow. For more information, see defaults.run.

When more than one default setting is defined with the same name, the orchestrator uses the most specific default setting. For example, a default setting defined in a job will override a default setting that has the same name defined in a workflow.

Example: Setting default run step options for a job

jobs:
  job1:
    runs-on: linux
    defaults:
      run:
        shell: bash
        working-directory: ./scripts