Customised notification template for Pipeline
Currently this feature is behind Feature Flag: PIPE_CUSTOM_NOTIFICATION_TEMPLATES
However, since this is supported for centralised notification, we need PL_CENTRAL_NOTIFICATIONS
and PIPE_CENTRALISED_NOTIFICATION
to be enabled first.
Users can now create notification templates, allowing users to customize notification content and reuse templates across multiple pipelines. Templates support Pipeline Expressions and RBAC controls, ensuring flexibility and security.
We are going to discuss about setting up notificatio template for Pipeline at a given scope.
You can set up notification template for Pipeline at following scope: Account, Organization and Project Level.
Setting Up Notifications Template
- Custom Notification template will work only with Centralized Notifications.
- Custom Notification templates will work only for webhook notifications.
- Custom notiification templates don't support usage of template variables.
- Interactive guide
- Step-by-step
In this example, we are going to discuss setting up notification template for Pipeline at Project Level:-
- In your Harness, go to your project.
- Select Project Settings, then, under Project-level resources, select Templates.
- Select + New Template, and then select Notifications. The Create New Notifications Template settings open.
- In Name, enter a name for the template.
- (Optional) Select the pencil icon to enter a Description.
- (Optional) Select the pencil icon to add Tags.
- In Version Label, enter the version of the template, for example,
v1
. Versioning a template enables you to create a new template without modifying the existing one. For more information, go to Versioning. - In Text Type you can choose text type as HTML, JSON, YAML or String for content body.
- When you select text type as per your need you will be asked to provide the body of notification template.
- Click on Save.
Now, let's add this notification template to a notification rule:-
-
In this example, we are going to discuss setting up notification management of Pipeline resource at Project Level:-
-
In Harness, go to Organization Settings.
-
Under General, select Notifications Management.
-
Under Overview, provide Notification Name and Continue to select Resource type.
-
Under Resources, Select Resource Type as Pipeline.
-
Under Condition , select + Add Condition to define pipeline events based on which you want to be notified.
Under events you can select the following pipeline events:-
- Pipeline Start
- Pipeline Success
- Pipeline Failed
- Stage Start
- Stage Success
- Stage Failed
Stage start/success/failed events will apply to all stages within a pipeline. There is no option to configure notifications for specific stages, if you want to do that you can configure it via Pipeline level notification.
Under Create Condition provide, Condition Name and Select Pipeline Events. Click on Continue to set channel where you want to send the notification.
-
Under Notification Templates, select your Notification template and select Use Template and click on Continue.
-
Under Set Channels, Select Channels where you want notification to be sent.
Under Select Channel you can chose the already created channel at that scope or you can create a New Channel.
- Select Submit to save your notification configuration.
You can also view Referenced By in your Notification Template to see notification rule it is attached to.
You can also check audit trail events for notification template created.
YAML Structure
YAML of notification template will look like:-
You can choose text type for your content body as HTML, JSON, YAML or String.
template:
name: Notification_template
identifier: Notification_template
versionLabel: v1
type: Notification
projectIdentifier: Krishika_test
orgIdentifier: default
tags: {}
spec:
body:
type: JSON
content: |-
{
"pipeline name" : "<+pipeline.name>",
"stage Name" : "<+stage.name>",
"service Name" : "deploy_azure_function",
"status" : "<+pipeline.status>"
}