22
33> v2.9 and after
44
5- ## Introduction
6-
7- Previous to version 2.8, the only way to specify dependencies in DAG templates was to use the ` dependencies ` field and
8- specify a list of other tasks the current task depends on. This syntax was limiting because it does not allow the user to
9- specify which _ result_ of the task to depend on. For example, a task may only be relevant to run if the dependent task
10- succeeded (or failed, etc.).
5+ Enhanced ` depends ` improves on [ the ` dependencies ` field] ( walk-through/dag.md ) by specifying which _ result_ of a task to depend on.
6+ For example, to only run a task if its dependent task succeeded.
117
128## Depends
139
14- To remedy this, there exists a new field called ` depends ` , which allows users to specify dependent tasks, their statuses,
15- as well as any complex boolean logic. The field is a ` string ` field and the syntax is expression-like with operands having
16- form ` <task-name>.<task-result> ` . Examples include ` task-1.Succeeded ` , ` task-2.Failed ` , ` task-3.Daemoned ` . The full list of
17- available task results is as follows:
18-
19- | Task Result | Description | Meaning |
20- | :------------:| ----------------| ---------|
21- | ` .Succeeded ` | Task Succeeded | Task finished with no error |
22- | ` .Failed ` | Task Failed | Task exited with a non-0 exit code |
23- | ` .Errored ` | Task Errored | Task had an error other than a non-0 exit code |
24- | ` .Skipped ` | Task Skipped | Task was skipped |
25- | ` .Omitted ` | Task Omitted | Task was omitted |
26- | ` .Daemoned ` | Task is Daemoned and is not Pending | |
10+ You can use the ` depends ` field to specify dependent tasks, their results, and boolean logic between them.
2711
28- A tasks is considered ` Skipped ` if its ` when ` condition evaluates to false. On the other hand, if a task doesn't run
29- because its ` depends ` evaluated to false it is ` Omitted ` .
12+ You use operands of the form ` <task-name>.<task-result> ` , such as ` task-1.Succeeded ` , ` task-2.Failed ` , ` task-3.Daemoned ` .
13+ Available task results are:
3014
31- For convenience, an omitted task result is equivalent to ` (task.Succeeded || task.Skipped || task.Daemoned) ` .
15+ | Task Result | Description |
16+ | :------------:| -------------|
17+ | ` .Succeeded ` | Task finished with no error |
18+ | ` .Failed ` | Task exited with a non-0 exit code |
19+ | ` .Errored ` | Task had an error other than a non-0 exit code |
20+ | ` .Skipped ` | Task's [ ` when ` ] ( walk-through/conditionals.md ) condition evaluated to ` false ` |
21+ | ` .Omitted ` | Task's ` depends ` condition evaluated to ` false ` |
22+ | ` .Daemoned ` | Task is [ daemoned] ( walk-through/daemon-containers.md ) and is not ` Pending ` |
3223
33- For example:
24+ For compatibility with ` dependencies ` , an unspecified result is equivalent to ` (task.Succeeded || task.Skipped || task.Daemoned) ` . For example:
3425
3526``` yaml
3627depends : " task || task-2.Failed"
@@ -42,30 +33,29 @@ is equivalent to:
4233depends : (task.Succeeded || task.Skipped || task.Daemoned) || task-2.Failed
4334` ` `
4435
45- Full boolean logic is also available. Operators include :
36+ You can use boolean logic with the operators :
4637
4738* ` &&`
4839* `||`
4940* `!`
5041
51- Example :
42+ Example :
5243
5344` ` ` yaml
5445depends: "(task-2.Succeeded || task-2.Skipped) && !task-3.Failed"
5546` ` `
5647
57- In the case that you're depending on a task that uses `withItems`, you can depend on
58- whether any of the item tasks are successful or all have failed using `.AnySucceeded` and `.AllFailed`, for example :
48+ If you depend on a task that uses `withItems`, you can use `.AnySucceeded` and `.AllFailed`. For example :
5949
6050` ` ` yaml
6151depends: "task-1.AnySucceeded || task-2.AllFailed"
6252` ` `
6353
6454# # Compatibility with `dependencies` and `dag.task.continueOn`
6555
66- This feature is fully compatible with `dependencies` and conversion is easy .
56+ You cannot use both `dependencies` and `depends` in the same task group .
6757
68- To convert simply join your `dependencies` with `&&` :
58+ To convert from `dependencies` to `depends`, join your array into a string with `&&`. For example :
6959
7060` ` ` yaml
7161dependencies: ["A", "B", "C"]
@@ -77,5 +67,4 @@ is equivalent to:
7767depends: "A && B && C"
7868` ` `
7969
80- Because of the added control found in `depends`, the `dag.task.continueOn` is not available when using it. Furthermore,
81- it is not possible to use both `dependencies` and `depends` in the same task group.
70+ ` dag.task.continueOn` is not available when using `depends`; instead you can specify `.Failed`.
0 commit comments