This repository has been archived by the owner on Feb 8, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new doc for conditional workflows, link to it in the api changes,…
… and add a note on the design doc to read the new doc for final design (#33)
- Loading branch information
Nathan Dintenfass
committed
Jul 16, 2019
1 parent
e42fb0e
commit 7e2a868
Showing
3 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Conditional Workflows | ||
New as of June 2019, you can use a `when` clause (and coming soon, also support for the inverse clause `unless`) under a workflow declaration with a boolean value to decide whether or not to run that workflow. | ||
|
||
The most common use of this construct is to use a [pipeline parameter](pipeline-parameters.md) as the value, allowing an API trigger to pass that parameter to determine which workflows to run. | ||
|
||
Below is an example configuration using two different pipeline parameters, one used to drive whether a particular workflow will run and another to determine if a particular step will run. | ||
|
||
```yaml | ||
version: 2.1 | ||
|
||
parameters: | ||
run_integration_tests: | ||
type: boolean | ||
default: false | ||
deploy: | ||
type: boolean | ||
default: false | ||
|
||
workflows: | ||
version: 2 | ||
integration_tests: | ||
when: << pipeline.parameters.run_integration_tests >> | ||
jobs: | ||
- mytestjob | ||
- when: | ||
condition: << pipeline.parameters.deploy >> | ||
steps: | ||
- deploy | ||
|
||
jobs: | ||
... | ||
``` | ||
|
||
The above would prevent the workflow `integration_tests` from being triggered | ||
unless it was invoked explicitly when the pipeline is triggered with the following in the POST body: | ||
|
||
```json | ||
{ | ||
"parameters": { | ||
"run_integration_tests": true | ||
} | ||
} | ||
``` | ||
|
||
The `when` key actually accepts any boolean, not just pipeline parameters, | ||
though pipeline parameters will be the primary use of this feature until we implement others. | ||
|
||
Coming soon: `when` also comes with an alternative of `unless`, which inverts truthiness of the condition. |