@@ -95,6 +95,24 @@ func TestJiraTemplating(t *testing.T) {
9595 },
9696 retry : false ,
9797 },
98+ {
99+ title : "template project" ,
100+ cfg : & config.JiraConfig {
101+ Project : `{{ .CommonLabels.lbl1 }}` ,
102+ Summary : `{{ template "jira.default.summary" . }}` ,
103+ Description : `{{ template "jira.default.description" . }}` ,
104+ },
105+ retry : false ,
106+ },
107+ {
108+ title : "template issue type" ,
109+ cfg : & config.JiraConfig {
110+ IssueType : `{{ .CommonLabels.lbl1 }}` ,
111+ Summary : `{{ template "jira.default.summary" . }}` ,
112+ Description : `{{ template "jira.default.description" . }}` ,
113+ },
114+ retry : false ,
115+ },
98116 {
99117 title : "summary with templating errors" ,
100118 cfg : & config.JiraConfig {
@@ -208,6 +226,51 @@ func TestJiraNotify(t *testing.T) {
208226 customFieldAssetFn : func (t * testing.T , issue map [string ]any ) {},
209227 errMsg : "" ,
210228 },
229+ {
230+ title : "create new issue with template project and issue type" ,
231+ cfg : & config.JiraConfig {
232+ Summary : `{{ template "jira.default.summary" . }}` ,
233+ Description : `{{ template "jira.default.description" . }}` ,
234+ IssueType : "{{ .CommonLabels.issue_type }}" ,
235+ Project : "{{ .CommonLabels.project }}" ,
236+ Priority : `{{ template "jira.default.priority" . }}` ,
237+ Labels : []string {"alertmanager" , "{{ .GroupLabels.alertname }}" },
238+ ReopenDuration : model .Duration (1 * time .Hour ),
239+ ReopenTransition : "REOPEN" ,
240+ ResolveTransition : "CLOSE" ,
241+ WontFixResolution : "WONTFIX" ,
242+ },
243+ alert : & types.Alert {
244+ Alert : model.Alert {
245+ Labels : model.LabelSet {
246+ "alertname" : "test" ,
247+ "instance" : "vm1" ,
248+ "severity" : "critical" ,
249+ "project" : "MONITORING" ,
250+ "issue_type" : "MINOR" ,
251+ },
252+ StartsAt : time .Now (),
253+ EndsAt : time .Now ().Add (time .Hour ),
254+ },
255+ },
256+ searchResponse : issueSearchResult {
257+ Total : 0 ,
258+ Issues : []issue {},
259+ },
260+ issue : issue {
261+ Key : "" ,
262+ Fields : & issueFields {
263+ Summary : "[FIRING:1] test (vm1 MINOR MONITORING critical)" ,
264+ Description : "\n \n # Alerts Firing:\n \n Labels:\n - alertname = test\n - instance = vm1\n - issue_type = MINOR\n - project = MONITORING\n - severity = critical\n \n Annotations:\n \n Source: \n \n \n \n \n " ,
265+ Issuetype : & idNameValue {Name : "MINOR" },
266+ Labels : []string {"ALERT{6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b}" , "alertmanager" , "test" },
267+ Project : & issueProject {Key : "MONITORING" },
268+ Priority : & idNameValue {Name : "High" },
269+ },
270+ },
271+ customFieldAssetFn : func (t * testing.T , issue map [string ]any ) {},
272+ errMsg : "" ,
273+ },
211274 {
212275 title : "create new issue with custom field and too long summary" ,
213276 cfg : & config.JiraConfig {
0 commit comments