diff --git a/docs/conditions.md b/docs/conditions.md index a16d98e77ee..80c83fd06cb 100644 --- a/docs/conditions.md +++ b/docs/conditions.md @@ -9,6 +9,7 @@ This document defines `Conditions` and their capabilities. - [Syntax](#syntax) - [Check](#check) - [Parameters](#parameters) + - [Resources](#resources) - [Examples](#examples) ## Syntax @@ -57,10 +58,31 @@ only start with alpha characters and `_`. For example, `fooIs-Bar_` is a valid parameter name, `barIsBa$` or `0banana` are not. Each declared parameter has a type field, assumed to be string if not provided by the user. -The other possible type is array — useful, checking a pushed branch name doesn't match any of +The other possible type is array — useful, for instance, checking that a pushed branch name doesn't match any of multiple protected branch names. When the actual parameter value is supplied, its parsed type is validated against the type field. +### Resources + +Conditions can declare input [`PipelineResources`](resources.md) via the `resources` field to +provide the Condition container step with data or context that is needed to perform the check. + +Input resources, like source code (git), are dumped at path +`/workspace/resource_name` within a mounted +[volume](https://kubernetes.io/docs/concepts/storage/volumes/). The condition container can use the `path` +[template](./tasks.md#Templating) key to refer to the local path to the mounted resource. + +```yaml +spec: + resources: + - name: workspace + type: git + check: + image: alpine + command: ["/bin/sh"] + args: ['-c', 'test -f ${resources.workspace.path}/README.md'] +``` + ## Examples For complete examples, see diff --git a/docs/pipelines.md b/docs/pipelines.md index d79464ea9a3..097e7b77585 100644 --- a/docs/pipelines.md +++ b/docs/pipelines.md @@ -304,6 +304,12 @@ tasks: name: build-push conditions: - conditionRef: my-condition + params: + - name: my-param + value: my-value + resources: + - name: workspace + resource: source-repo ``` In this example, `my-condition` refers to a [Condition](#conditions) custom resource. The `build-push`