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.
Rename function `ApplyPipelineTaskContext` to `ApplyPipelineTaskStateContext` in
"pipelinerun/apply.go" to distinguish from `ApplyPipelineTaskContexts`.
-[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,35 @@ 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-retries-parameter)
555
+
parameter of `PipelineTask`. Variables 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
+
params:
562
+
- name: pipelineTask-retries
563
+
value: "$(context.pipelineTask.retries)"
564
+
taskSpec:
565
+
params:
566
+
- name: pipelineTask-retries
567
+
steps:
568
+
- image: ubuntu
569
+
name: print-if-retries-exhausted
570
+
script: |
571
+
if [ "$(context.task.retry-count)" == "$(params.pipelineTask-retries)" ]
572
+
then
573
+
echo "This is the last retry."
574
+
fi
575
+
exit 1
576
+
```
577
+
578
+
**Note:** Every `PipelineTask` can only access its own `retries` and`retry-count`. These
579
+
values aren't accessible for other `PipelineTask`s.
580
+
551
581
## Using `Results`
552
582
553
583
Tasks can emit [`Results`](tasks.md#emitting-results) when they execute. A Pipeline can use these
0 commit comments