-
Notifications
You must be signed in to change notification settings - Fork 0
Template Field Reference
Every field on the domain.Event struct is available in your templates. This page documents each field, its type, where it comes from, and when it's populated. Use this as a lookup while writing templates.
All fields are accessed with a leading dot in templates (e.g., {{ .State }}). Pointer fields (*int) must be guarded before dereferencing.
| Field | Type | Description | Example values |
|---|---|---|---|
.Provider |
string |
SCM provider name from the scm.provider annotation |
github, gitlab, gitea, bitbucket, azure_devops, sourcehut
|
.Resource |
Resource |
Type of Kubernetes resource that emitted the event |
taskrun, pipelinerun, customrun, eventlistener
|
.APIBaseURL |
string |
Base URL override for self-hosted SCM instances | https://github.mycompany.com/api/v3 |
| Field | Type | Description | Example values |
|---|---|---|---|
.RunName |
string |
Name of the TaskRun, PipelineRun, or CustomRun |
build-abc12, my-pipeline-run-7k9z
|
.RunID |
string |
Unique identifier (metadata.uid) | a1b2c3d4-e5f6-7890-abcd-ef1234567890 |
.Namespace |
string |
Kubernetes namespace |
default, production, tekton-ci
|
| Field | Type | Description | Example values |
|---|---|---|---|
.TaskName |
string |
Referenced Task spec name (from tekton.dev/task label) |
build, test-unit, deploy-staging
|
.PipelineName |
string |
Referenced Pipeline spec name (from tekton.dev/pipeline label) |
my-pipeline, release-v2
|
.PipelineTaskName |
string |
Task name within the Pipeline (from tekton.dev/pipelineTask label) |
run-tests, build-image
|
.EventListenerName |
string |
EventListener that processed the trigger |
github-listener, ci-trigger
|
.TriggerName |
string |
Tekton Trigger name (from triggers.tekton.dev/trigger label) |
push-trigger, pr-trigger
|
| Field | Type | Description | Example values |
|---|---|---|---|
.TaskDisplayName |
string |
Human-readable Task name from spec |
Run Unit Tests, Build Container Image
|
.PipelineDisplayName |
string |
Human-readable Pipeline name from spec |
CI Pipeline, Release Process
|
| Field | Type | Description | Example values |
|---|---|---|---|
.IsFinallyTask |
bool |
True if the task belongs to the finally block (from tekton.dev/memberOf label) |
true, false
|
.SCMEventType |
string |
Webhook event type from EventListener headers (e.g., issues, pull_request, push) |
pull_request, push, issues
|
.TaskCount |
int |
Number of child tasks (from PipelineRun status.childReferences length) |
0, 5, 12
|
| Field | Type | Description | Possible values |
|---|---|---|---|
.State |
State |
Logical execution state |
pending, running, success, failure, error, canceled, done
|
.Context |
string |
Logical check name (default: tekton/build) |
tekton/build, tekton/pipeline-summary
|
.Description |
string |
Short human-readable message |
Build succeeded, Task failed: test-unit
|
.TargetURL |
string |
Clickable link to the Tekton Dashboard | https://dashboard.example.com/#/namespaces/default/pipelineruns/my-run |
| Field | Type | Description | Example values |
|---|---|---|---|
.CommitSHA |
string |
Full commit SHA | abc1234567890def1234567890abcdef12345678 |
.Repo.Owner |
string |
Repository owner (GitHub, Gitea, SourceHut) |
my-org, alice
|
.Repo.Name |
string |
Repository name |
my-repo, backend-api
|
.Repo.ID |
string |
Numeric project ID (GitLab) | 12345678 |
.Repo.Workspace |
string |
Workspace name (Bitbucket Cloud) | my-workspace |
.Repo.Project |
string |
Project name (Bitbucket Server, Azure DevOps) |
my-project, DefaultProject
|
.Repo.Org |
string |
Organization name (Azure DevOps) | my-org |
| Field | Type | Description | Example values |
|---|---|---|---|
.IssueNumber |
*int |
Issue number from annotation |
42, nil
|
.PRNumber |
*int |
Pull request number from annotation |
123, nil
|
.DiscussionNumber |
*int |
Discussion number from annotation |
5, nil
|
.JiraIssueKey |
string |
Jira issue key from annotation |
PROJ-123, ""
|
| Field | Type | Description | Example values |
|---|---|---|---|
.Results |
[]Result |
Task/Pipeline results (slice of {Name, Value}) |
See below |
Result items:
{{- range .Results }}
Name: {{ .Name }}, Value: {{ .Value }}
{{- end }}
Common result names from Tekton:
-
IMAGE_DIGEST— container image digest -
IMAGE_URL— container image URL -
COMMIT_SHA— commit SHA (if set by the pipeline) -
CHANGES— changed files list
| Field | Type | Description | Example values |
|---|---|---|---|
.StartedAt |
time.Time |
Execution start time | 2024-01-15T10:30:00Z |
.FinishedAt |
time.Time |
Execution end time | 2024-01-15T10:35:45Z |
Both are zero-valued when not yet set. Guard with .IsZero:
{{- if and (not .StartedAt.IsZero) (not .FinishedAt.IsZero) }}
Started: {{ .StartedAt.Format "2006-01-02 15:04:05 MST" }}
Duration: {{ regexReplaceAll "[.][0-9]+s" (toString (.FinishedAt.Sub .StartedAt)) "s" }}
{{- end }}
Which decoder sets which fields. Checkmarks indicate the decoder populates the field. Blank means the field is zero/empty for that resource type.
| Field | TaskRun | PipelineRun | CustomRun | EventListener |
|---|---|---|---|---|
.Provider |
✅ | ✅ | ✅ | ✅ |
.Resource |
✅ | ✅ | ✅ | ✅ |
.APIBaseURL |
✅ | ✅ | ✅ | ✅ |
.RunName |
✅ | ✅ | ✅ | ✅ |
.RunID |
✅ | ✅ | ✅ | ✅ |
.Namespace |
✅ | ✅ | ✅ | ✅ |
.TaskName |
✅ | — | — | — |
.PipelineName |
✅ | ✅ | — | — |
.PipelineTaskName |
✅ | — | — | — |
.EventListenerName |
— | — | — | ✅ |
.TriggerName |
— | — | — | — |
.TaskDisplayName |
✅ | ✅ | — | — |
.PipelineDisplayName |
— | ✅ | — | — |
.IsFinallyTask |
✅ | — | — | — |
.SCMEventType |
— | — | — | ✅ |
.TaskCount |
— | ✅ | — | — |
.State |
✅ | ✅ | ✅ | ✅ |
.Context |
✅ | ✅ | ✅ | ✅ |
.Description |
✅ | ✅ | ✅ | ✅ |
.TargetURL |
✅ | ✅ | ✅ | — |
.CommitSHA |
✅ | ✅ | ✅ | ✅ |
.Repo.* |
✅ | ✅ | ✅ | ✅ |
.IssueNumber |
✅ | ✅ | ✅ | — |
.PRNumber |
✅ | ✅ | ✅ | — |
.DiscussionNumber |
✅ | ✅ | ✅ | — |
.JiraIssueKey |
✅ | ✅ | ✅ | — |
.Results |
✅ | ✅ | ✅ | — |
.StartedAt |
✅ | ✅ | ✅ | — |
.FinishedAt |
✅ | ✅ | ✅ | — |
The .State field maps from the CloudEvent type suffix:
| CloudEvent suffix |
.State value |
Description |
|---|---|---|
queued |
pending |
Event queued, not yet executing |
started |
running |
Execution started |
running |
running |
Execution in progress |
succeeded |
success |
Execution completed successfully |
failed |
failure |
Execution failed |
cancelled |
canceled |
Execution was cancelled |
unknown |
running |
Unknown state (treated as running) |
successful |
success |
EventListener success |
done |
done |
EventListener completion |
The accumulator uses a different data type than the standard domain.Event. Templates receive a SummaryData struct:
| Field | Type | Description | Example values |
|---|---|---|---|
.PipelineName |
string |
Pipeline name | my-pipeline |
.RunName |
string |
PipelineRun name | my-pipeline-run-abc |
.State |
string |
Terminal state |
success, failure, error, canceled
|
.Tasks |
[]TaskSummary |
Sorted list of task summaries | See below |
TaskSummary fields:
| Field | Type | Description | Example values |
|---|---|---|---|
.Name |
string |
Task name |
build, test, deploy
|
.State |
string |
Task state |
success, failure, running
|
.Emoji |
string |
State emoji |
✅, ❌, ⚠️, 🚫, 🔄, ⏳
|
.Duration |
string |
Formatted duration |
45s, 1m20s, N/A
|
The accumulator template does NOT have access to domain.Event fields. Use SummaryData fields only.
## Pipeline {{ .State }}
**Pipeline:** {{ .PipelineName | default .RunName }}
**Run:** `{{ .RunName }}`
**Namespace:** {{ .Namespace }}
{{- if .CommitSHA }}
**Commit:** `{{ .CommitSHA | trunc 8 }}`
{{- end }}
{{- if and (not .StartedAt.IsZero) (not .FinishedAt.IsZero) }}
**Duration:** {{ regexReplaceAll "[.][0-9]+s" (toString (.FinishedAt.Sub .StartedAt)) "s" }}
{{- end }}
{{- if .Results }}
### Results
| Name | Value |
|---|---|
{{- range .Results }}
| `{{ .Name }}` | `{{ Truncate .Value 120 }}` |
{{- end }}
{{- end }}
{{- if eq .Resource "pipelinerun" }}
Pipeline: {{ .PipelineName }}
Tasks: {{ .TaskCount }}
{{- else if eq .Resource "taskrun" }}
Task: {{ .TaskName }}
{{- if .IsFinallyTask }}(finally task){{ end }}
{{- end }}
{{- if .PRNumber }}
Pull Request: {{ PRRef .Provider .PRNumber .Repo.Owner .Repo.Name }}
{{- else if .IssueNumber }}
Issue: {{ IssueRef .Provider .IssueNumber .Repo.Owner .Repo.Name }}
{{- end }}
Getting started
Reference
SCM providers
Notifiers
Running in production
More