Skip to main content

Overriding scope service workflows

How to override a base service workflow

To override or add configurations to your base workflow file, run the following command:

np service workflow exec --workflow $path_to_workflow_file --overrides $path_to_overrides_file

Use the --overrides flag to modify the steps defined in the base workflow file:

  • merge - merges configurations with the base definition
  • replace - replaces a configuration of the base workflow file
  • skip - skips a step from the base workflow file
  • add - adds a step in the based workflow file
tip

You can include the --dry-run flag, which returns a final .yaml file instead of executing the command.

This file shows the applied overrides to the base workflow.

Example: updating a base service workflow

We'll use the following base workflow file as an example:

steps:
- name: step 1
type: command
command: echo "first step"
- name: step 2
type: script
file: final-step.sh
configuration:
env: production

The example above will be updated depending on the new configurations defined in the overrides file.

Below are examples of override configurations that will either merge, replace, skip, or add steps to your base workflow file.

Merging configurations

New configurations added in the overrides file:

steps:
- name: step 2
configuration:
extra: configurations
post:
type: command
command: echo "validate step"

Resulting configuration:

steps:
- name: step 1
type: command
command: echo "first step"
- name: step 2
type: script
file: final-step.sh
configuration:
env: production
extra: configurations // extra configuration
post: // new post script
type: command
command: echo "validate step"
Replacing configurations

New configurations added in the overrides file:

warning

You must provide the complete definition of the step you want to replace.

steps:
- name: step 2
type: script
action: replace
file: other-step.sh
configuration:
extra: configurations
post:
type: command
command: echo "validate step"

Resulting configuration:

steps:
- name: step 1
type: command
command: echo "first step"
- name: step 2
type: script
file: other-step.sh // replaced step
configuration:
extra: configurations
post:
type: command
command: echo "validate step"
Skipping steps

New configurations added in the overrides file:

steps:
- name: step 2
action: skip

Resulting configuration:

  steps:
- name: step 1 //only step one is executed
type: command
command: echo "first step"
Adding steps

New configurations added in the overrides file:

  steps:
- name: step 0 // new step
type: command
command: echo "I will be executed first!"
before: step 1 // defines when in the workflow the step will be executed
- name: step 3
type: command
command: echo "I will be executed last!"
after: step 2

Resulting configuration:

steps:
- name: step 0 // new step executed first
type: command
command: echo "I will be executed first!"
- name: step 1
type: command
command: echo "first step"
- name: step 2
type: script
file: final-step.sh
configuration:
env: production
- name: step 3
type: command
command: echo "I will be executed last!"