You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add 2 variables context.pipelineTask.retries and context.task.retry-count
`context.pipelineTask.retries` exposes the total retries of a pipelineTask.
`context.task.retry-count` exposes the current number of retry. The reason why the
variable isn't `context.pipelineTask.retry-count` is that every task has a retry
count, only pipelineTask has retries.
-[Using the `retries` and `retry-count` variable substitutions](#using-the-retries-and-retry-count-variable-substitutions)
23
24
-[Using `Results`](#using-results)
24
25
-[Passing one Task's `Results` into the `Parameters` or `WhenExpressions` of another](#passing-one-tasks-results-into-the-parameters-or-whenexpressions-of-another)
25
26
-[Emitting `Results` from a `Pipeline`](#emitting-results-from-a-pipeline)
@@ -548,6 +549,29 @@ performed by the Tekton Controller when a PipelineRun is executed.
548
549
See the [complete list of variable substitutions for Pipelines](./variables.md#variables-available-in-a-pipeline)
549
550
and the [list of fields that accept substitutions](./variables.md#fields-that-accept-variable-substitutions).
550
551
552
+
### Using the `retries` and `retry-count` variable substitutions
553
+
554
+
Tekton supports variable substitution for the [`retries`](#using-the-runafter-parameter)
555
+
parameter of `PipelineTask`. Varibles like `context.pipelineTask.retries` and
556
+
`context.task.retry-count`can be injected into the content of a `PipelineTask`.
557
+
`context.pipelineTask.retries`will be replaced by `retries` of the `PipelineTask`, while
558
+
`context.task.retry-count`will be replaced by current retry number of the `PipelineTask`.
559
+
560
+
```yaml
561
+
steps:
562
+
- image: ubuntu
563
+
name: print-if-retries-exhausted
564
+
script: |
565
+
if [ "$(context.task.retry-count)" == "$(context.pipelineTask.retries)" ]
566
+
then
567
+
echo "This is the last retry."
568
+
fi
569
+
exit 1
570
+
```
571
+
572
+
**Note:** Every `PipelineTask` can only access its own `retries` and`retry-count`. These
573
+
values aren't accessible for other `PipelineTask`s.
574
+
551
575
## Using `Results`
552
576
553
577
Tasks can emit [`Results`](tasks.md#emitting-results) when they execute. A Pipeline can use these
0 commit comments