Skip to content

Commit

Permalink
Add intial skeleton docs for conditions
Browse files Browse the repository at this point in the history
Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
  • Loading branch information
dibyom committed Jul 29, 2019
1 parent c8174e7 commit 9b97042
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
52 changes: 52 additions & 0 deletions docs/conditions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Conditions

This document defines `Conditions` and their capabilities.

*NOTE*: This feature is currently a WIP.

---

- [Syntax](#syntax)
- [Check](#check)
- [Parameters](#parameters)

- [Examples](#examples)

## Syntax

To define a configuration file for a `Condition` resource, you can specify the
following fields:

- Required:
- [`apiVersion`][kubernetes-overview] - Specifies the API version, for example
`tekton.dev/v1alpha1`.
- [`kind`][kubernetes-overview] - Specify the `Condition` resource object.
- [`metadata`][kubernetes-overview] - Specifies data to uniquely identify the
`Condition` resource object, for example a `name`.
- [`spec`][kubernetes-overview] - Specifies the configuration information for
your `Condition` resource object. In order for a `Condition` to do anything,
the spec must include:
- [`check`](#check) - Specifies a container that you want to run for evaluating the condition

[kubernetes-overview]:
https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/#required-fields

### Check

The `check` field is required. You define a single check to define the body of a `Condition`. The
check must specify a container image that adheres to the container contract. The container image
runs till completion. The container must exit successfully i.e. with an exit code 0 for the
condition evaluation to be successful. All other exit codes are considered to be a condition check
failure.

## Examples

For complete examples, see
[the examples folder](https://github.com/tektoncd/pipeline/tree/master/examples).

---

Except as otherwise noted, the content of this page is licensed under the
[Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/),
and code samples are licensed under the
[Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0).
24 changes: 24 additions & 0 deletions docs/pipelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ following fields:
- [`retries`](#retries) - Used when the task is wanted to be executed if
it fails. Could a network error or a missing dependency. It does not
apply to cancellations.
- [`conditions`](#conditions) - Used when a task is to be executed only if the specified
conditons are evaluated to be true.

[kubernetes-overview]:
https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/#required-fields
Expand Down Expand Up @@ -282,6 +284,28 @@ In this example, the task "build-the-image" will be executed and if the first
run fails a second one would triggered. But, if that fails no more would
triggered: a max of two executions.


#### conditions

Sometimes you will need to run tasks only when some conditions are true. The `conditions` field
allows you to list a series of references to [`Conditions`](#conditions) that are run before the task
is run. If all of the conditions evaluate to true, the task is run. If any of the conditions are false,
the Task is not run. Its status.ConditionSucceeded is set to False with the reason set to `ConditionCheckFailed`.
However, unlike regular task failures, condition failures do not automatically fail the entire pipeline
run -- other tasks in the pipeline are still run.

```yaml
tasks:
- name: conditional-task
taskRef:
name: build-push
conditions:
- conditionRef: my-condition
```

In this example, `my-condition` refers to a [Condition](#conditions) custom resource. The `build-push`
task will only be executed if the condition evaluates to true.

## Ordering

The [Pipeline Tasks](#pipeline-tasks) in a `Pipeline` can be connected and run
Expand Down

0 comments on commit 9b97042

Please sign in to comment.