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.

Field summary

All fields are accessed with a leading dot in templates (e.g., {{ .State }}). Pointer fields (*int) must be guarded before dereferencing.

Routing fields

FieldTypeDescriptionExample values
.ProviderstringSCM provider name from the scm.provider annotationgithub, gitlab, gitea, bitbucket, azure_devops, sourcehut
.ResourceResourceType of Kubernetes resource that emitted the eventtaskrun, pipelinerun, customrun, eventlistener
.APIBaseURLstringBase URL override for self-hosted SCM instanceshttps://github.mycompany.com/api/v3

Pipeline identity

FieldTypeDescriptionExample values
.RunNamestringName of the TaskRun, PipelineRun, or CustomRunbuild-abc12, my-pipeline-run-7k9z
.RunIDstringUnique identifier (metadata.uid)a1b2c3d4-e5f6-7890-abcd-ef1234567890
.NamespacestringKubernetes namespacedefault, production, tekton-ci

Resource-specific names

FieldTypeDescriptionExample values
.TaskNamestringReferenced Task spec name (from tekton.dev/task label)build, test-unit, deploy-staging
.PipelineNamestringReferenced Pipeline spec name (from tekton.dev/pipeline label)my-pipeline, release-v2
.PipelineTaskNamestringTask name within the Pipeline (from tekton.dev/pipelineTask label)run-tests, build-image
.EventListenerNamestringEventListener that processed the triggergithub-listener, ci-trigger
.TriggerNamestringTekton Trigger name (from triggers.tekton.dev/trigger label)push-trigger, pr-trigger

Display names

FieldTypeDescriptionExample values
.TaskDisplayNamestringHuman-readable Task name from specRun Unit Tests, Build Container Image
.PipelineDisplayNamestringHuman-readable Pipeline name from specCI Pipeline, Release Process

Status flags

FieldTypeDescriptionExample values
.IsFinallyTaskboolTrue if the task belongs to the finally block (from tekton.dev/memberOf label)true, false
.SCMEventTypestringWebhook event type from EventListener headers (e.g., issues, pull_request, push)pull_request, push, issues
.TaskCountintNumber of child tasks (from PipelineRun status.childReferences length)0, 5, 12

State

FieldTypeDescriptionPossible values
.StateStateLogical execution statepending, running, success, failure, error, canceled, done
.ContextstringLogical check name (default: tekton/build)tekton/build, tekton/pipeline-summary
.DescriptionstringShort human-readable messageBuild succeeded, Task failed: test-unit
.TargetURLstringClickable link to the Tekton Dashboardhttps://dashboard.example.com/#/namespaces/default/pipelineruns/my-run

SCM fields

FieldTypeDescriptionExample values
.CommitSHAstringFull commit SHAabc1234567890def1234567890abcdef12345678
.Repo.OwnerstringRepository owner (GitHub, Gitea, SourceHut)my-org, alice
.Repo.NamestringRepository namemy-repo, backend-api
.Repo.IDstringNumeric project ID (GitLab)12345678
.Repo.WorkspacestringWorkspace name (Bitbucket Cloud)my-workspace
.Repo.ProjectstringProject name (Bitbucket Server, Azure DevOps)my-project, DefaultProject
.Repo.OrgstringOrganization name (Azure DevOps)my-org

Linking fields (pointer types, guard before use)

FieldTypeDescriptionExample values
.IssueNumber*intIssue number from annotation42, nil
.PRNumber*intPull request number from annotation123, nil
.DiscussionNumber*intDiscussion number from annotation5, nil
.JiraIssueKeystringJira issue key from annotationPROJ-123, ""

Results

FieldTypeDescriptionExample values
.Results[]ResultTask/Pipeline results (slice of {Name, Value})See below

Result items:

{{- range .Results }}
  Name: {{ .Name }}, Value: {{ .Value }}
{{- end }}

Common result names from Tekton:

Timing

FieldTypeDescriptionExample values
.StartedAttime.TimeExecution start time2024-01-15T10:30:00Z
.FinishedAttime.TimeExecution end time2024-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 }}

Decoder population matrix

Which decoder sets which fields. Checkmarks indicate the decoder populates the field. Blank means the field is zero/empty for that resource type.

FieldTaskRunPipelineRunCustomRunEventListener
.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βœ…βœ…βœ…β€”

State values

The .State field maps from the CloudEvent type suffix:

CloudEvent suffix.State valueDescription
queuedpendingEvent queued, not yet executing
startedrunningExecution started
runningrunningExecution in progress
succeededsuccessExecution completed successfully
failedfailureExecution failed
cancelledcanceledExecution was cancelled
unknownrunningUnknown state (treated as running)
successfulsuccessEventListener success
donedoneEventListener completion

Accumulator SummaryData

The accumulator uses a different data type than the standard domain.Event. Templates receive a SummaryData struct:

FieldTypeDescriptionExample values
.PipelineNamestringPipeline namemy-pipeline
.RunNamestringPipelineRun namemy-pipeline-run-abc
.StatestringTerminal statesuccess, failure, error, canceled
.Tasks[]TaskSummarySorted list of task summariesSee below

TaskSummary fields:

FieldTypeDescriptionExample values
.NamestringTask namebuild, test, deploy
.StatestringTask statesuccess, failure, running
.EmojistringState emojiβœ…, ❌, ⚠️, 🚫, πŸ”„, ⏳
.DurationstringFormatted duration45s, 1m20s, N/A

The accumulator template does NOT have access to domain.Event fields. Use SummaryData fields only.

Template examples by field

Pipeline summary with results

## 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 }}

Conditional content by resource type

{{- if eq .Resource "pipelinerun" }}
Pipeline: {{ .PipelineName }}
Tasks: {{ .TaskCount }}
{{- else if eq .Resource "taskrun" }}
Task: {{ .TaskName }}
{{- if .IsFinallyTask }}(finally task){{ end }}
{{- end }}

Provider-specific issue reference

{{- if .PRNumber }}
Pull Request: {{ PRRef .Provider .PRNumber .Repo.Owner .Repo.Name }}
{{- else if .IssueNumber }}
Issue: {{ IssueRef .Provider .IssueNumber .Repo.Owner .Repo.Name }}
{{- end }}