Skip to content

Commit 0721a03

Browse files
enhance(docs): add eval ruleset (#60)
Co-authored-by: david may <1301201+wass3r@users.noreply.github.com>
1 parent 8af9e6f commit 0721a03

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/reference/yaml/steps.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ The following rules can be used to configure a ruleset:
129129
| `status` | name of status for a build. |
130130
| `tag` | name of reference for a build. |
131131
| `target` | name of deployment or schedule target for a build. |
132+
| `eval` | [expr](https://expr-lang.org/) query to evaluate. |
132133

133134
```yaml
134135
---
@@ -260,6 +261,33 @@ steps:
260261
target: [ dev/*, test/* ]
261262
```
262263

264+
:::tip
265+
Eval utilizes the [expr query language](https://expr-lang.org/) to assess the ruleset. The eval key can be used alongside other ruleset keys, provided that all rulesets return true the step will run. For a deeper understanding of the syntax, refer to the expr documentation available at https://expr-lang.org/docs/language-definition. All environment variables mentioned within [variable documentation](/docs/reference/environment/variables.md) can be used within the expression. However, conditionally available variables (such as `VELA_BUILD_TAG` outside of a tag event) won't always be populated. You can still include them in the query, but they will evaluate to an empty string in those cases.
266+
:::
267+
268+
```yaml
269+
---
270+
steps:
271+
- name: simple-match
272+
ruleset:
273+
eval: "VELA_BUILD_AUTHOR == 'Octocat'"
274+
commands:
275+
- echo "this will only run if the build author name is Octocat"
276+
277+
- name: function-match
278+
ruleset:
279+
eval: "hasPrefix(VELA_BUILD_AUTHOR, 'Octo')"
280+
commands:
281+
- echo "this will only run if the build author name has the prefix of Octo"
282+
283+
- name: new-and-old
284+
ruleset:
285+
eval: "VELA_BUILD_AUTHOR == 'Octocat'"
286+
event: [tag]
287+
commands:
288+
- echo "this will only run if Octocat triggered the tag event"
289+
```
290+
263291
The following controls can be used to modify the behavior of the ruleset evaluation:
264292

265293
| Name | Description | Options |

0 commit comments

Comments
 (0)