Configure Custom Mail Templates
TOC
IntroductionScenariosPrerequisitesTemplate Support in Send MailSteps1. Create a template ConfigMap2. Configure pipeline to use your template3. Verify rendering resultsFAQDo I have to configurestyle.tekton.dev/descriptors?Can I use both built-in variables and values.xxx in the same template?What happens if renderTemplateName is not set?Which namespace should I use for template ConfigMap?What should I check first when rendering does not work?Introduction
This guide explains how to add a new custom mail notification template for the Send Mail Task.
Scenarios
For most use cases, use built-in templates first:
- Default Mail Template: outputs basic information of the current PipelineRun.
- Custom Mail Template: supports custom email content through provided template options.
If built-in templates do not meet your requirements, follow this guide to create and configure a new template.
Prerequisites
Send MailTask is available in your cluster.- You have permission to create
ConfigMapin the target template namespace.
Template Support in Send Mail
The Send Mail Task supports template-based rendering for subject, body, and contentType.
By referencing a shared template ConfigMap, teams can maintain mail content globally and reuse the same template across multiple pipelines.
For rendering workflow, built-in variables, and renderTemplateValues details, see Supported Template Parameters for Tasks.
Steps
1. Create a template ConfigMap
Create a ConfigMap and set parameters as follows:
Recommended namespace:
- Place template
ConfigMapinkube-publicwhenever possible.kube-publicis a commonly used shared namespace, which makes it easier forTaskRunresources from different namespaces to reuse the same template. - If you store the template in another namespace, explicitly set
renderTemplateNamespaceto that namespace in your Task/Pipeline parameters. For details, see Supported Template Parameters for Tasks.
Required parameters:
- Label
tekton.alaudadevops.io/template-type: mail: marks thisConfigMapas a mail template so the webhook can identify it as a render source forSend Mail. - Data keys
subject.tpl,body.tpl,contentType.tpl: rendered with Go template (gotemplate) syntax and mapped tosubject,body, andcontentTypeparams. For gotemplate syntax, see Gotext/templatedocumentation. For available template variables, see Supported Template Parameters for Tasks.
Optional parameters:
- Annotation
tekton.alaudadevops.io/template-display-name: human-readable name shown in UI selectors and preview panels. - Annotation
style.tekton.dev/descriptors: defines a nested form forrenderTemplateValuesin UI, so users can fill template variables with form controls instead of manually editing YAML. For descriptor syntax and patterns, see How to Configure Dynamic Forms.
Example:
2. Configure pipeline to use your template
Set renderTemplateName and renderTemplateNamespace, then pass custom values through renderTemplateValues.
3. Verify rendering results
Check a mutated TaskRun and confirm subject, body, and contentType have been appended to spec.params.
If rendering fails, check TaskRun annotation tekton.alaudadevops.io/template-render-error.
FAQ
Do I have to configure style.tekton.dev/descriptors?
No. It is optional. Configure it only when you want a structured UI form for renderTemplateValues.
Can I use both built-in variables and values.xxx in the same template?
Yes. You can combine built-in variables (for example, .context.pipelineRun.name, .tasks.status) with user values such as .values.extraMessage.
What happens if renderTemplateName is not set?
Template rendering is skipped. You need to provide subject and body params manually.
Which namespace should I use for template ConfigMap?
Use kube-public whenever possible. It is a common shared namespace, making it easier for TaskRun resources across different namespaces to reuse the same template.
If the template ConfigMap is stored in another namespace, set renderTemplateNamespace explicitly to that namespace. For parameter details, see Supported Template Parameters for Tasks.
What should I check first when rendering does not work?
- Confirm
renderTemplateNameandrenderTemplateNamespacepoint to an existing templateConfigMap. - Confirm the
ConfigMapincludes labeltekton.alaudadevops.io/template-type: mailand required keyssubject.tpl,body.tpl, andcontentType.tpl. - Check TaskRun annotation
tekton.alaudadevops.io/template-render-errorfor the concrete error message.