If you need to pass a parameter (and its associated value) from the Setup Workflow to the Continuation Workflow, you can leverage the `parameters` parameter of the continuation orb's `continue` command.
This is typically useful if you want the execution of the Continuation Workflow to depend on logic statements.
Prerequisites
This guide assumes that you have some familiarity with Dynamic Configuration.
Instructions
Below is an example of the config.yml
for the Setup Workflow:
version: 2.1
setup: true
orbs:
continuation: circleci/continuation@0.3.1
jobs:
set-param:
docker:
- image: cimg/node:19.6.1
steps:
- continuation/continue:
parameters: { "further": true }
configuration_path: ./config_continue.yml
workflows:
use-my-orb:
jobs:
- set-param
Below is an example the continue.yml
for the Continuation Workflow:
version: 2.1
parameters:
further:
type: boolean
default: false
jobs:
module-build:
docker:
- image: cimg/node:19.6.1
steps:
- run:
name: Check directory
command: pwd
workflows:
module-workflow:
when: << pipeline.parameters.further >>
jobs:
- module-build
Outcome
In the above scenario, the module-workflow will only execute if you specified parameters: { "further": true }
when invoking the continuation/continue
command.
Additional Notes
You can pass several parameters when invoking the continuation/continue
command; however they need to be part of the same JSON object. For example:
steps:
- continuation/continue:
parameters: { "further": true, "other_param": "a_string" }
configuration_path: ./config_continue.yml
(Note the absence of double-quotes around the boolean's value)
The parameters
parameter accepts either a JSON object or a path to a file containing a JSON object. So the following is also valid:
steps:
- run: echo '{ "further": true, "other_param": "a_string" }' > /home/circleci/parameters.json
- continuation/continue:
parameters: /home/circleci/parameters.json
configuration_path: ./config_continue.yml
Comments
Article is closed for comments.