Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions config/notifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,10 +905,11 @@ type JiraConfig struct {
Priority string `yaml:"priority,omitempty" json:"priority,omitempty"`
IssueType string `yaml:"issue_type,omitempty" json:"issue_type,omitempty"`

ReopenTransition string `yaml:"reopen_transition,omitempty" json:"reopen_transition,omitempty"`
ResolveTransition string `yaml:"resolve_transition,omitempty" json:"resolve_transition,omitempty"`
WontFixResolution string `yaml:"wont_fix_resolution,omitempty" json:"wont_fix_resolution,omitempty"`
ReopenDuration model.Duration `yaml:"reopen_duration,omitempty" json:"reopen_duration,omitempty"`
DisableFieldUpdates bool `yaml:"disable_field_updates,omitempty" json:"disable_field_updates,omitempty"`
ReopenTransition string `yaml:"reopen_transition,omitempty" json:"reopen_transition,omitempty"`
ResolveTransition string `yaml:"resolve_transition,omitempty" json:"resolve_transition,omitempty"`
WontFixResolution string `yaml:"wont_fix_resolution,omitempty" json:"wont_fix_resolution,omitempty"`
ReopenDuration model.Duration `yaml:"reopen_duration,omitempty" json:"reopen_duration,omitempty"`

Fields map[string]any `yaml:"fields,omitempty" json:"custom_fields,omitempty"`
}
Expand Down
4 changes: 4 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,10 @@ labels:
# Type of the issue (e.g. Bug).
[ issue_type: <string> ]

# Disable updates to fields once an issue is created. If false, the alertmanager will overwrite changes after every notification.
# NOTE: Disabling field updates does not disable transitions.
[ disable_field_updates: <boolean> | default = false ]

# Name of the workflow transition to resolve an issue. The target status must have the category "done".
# NOTE: The name of the transition can be localized and depends on the language setting of the service account.
[ resolve_transition: <string> ]
Expand Down
3 changes: 3 additions & 0 deletions notify/jira/jira.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)

logger.Debug("create new issue")
} else {
if n.conf.DisableFieldUpdates {
return n.transitionIssue(ctx, logger, existingIssue, alerts.HasFiring())
}
path = "issue/" + existingIssue.Key
method = http.MethodPut

Expand Down
49 changes: 49 additions & 0 deletions notify/jira/jira_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,55 @@ func TestJiraNotify(t *testing.T) {
customFieldAssetFn: func(t *testing.T, issue map[string]any) {},
errMsg: "can't find transition REOPEN for issue OPS-3",
},
{
title: "skip update request when DisableFieldUpdates is true",
cfg: &config.JiraConfig{
Summary: `{{ template "jira.default.summary" . }}`,
Description: `{{ template "jira.default.description" . }}`,
IssueType: "{{ .CommonLabels.issue_type }}",
Project: "{{ .CommonLabels.project }}",
Priority: `{{ template "jira.default.priority" . }}`,
Labels: []string{"alertmanager", "{{ .GroupLabels.alertname }}"},
DisableFieldUpdates: true,
},
alert: &types.Alert{
Alert: model.Alert{
Labels: model.LabelSet{
"alertname": "DisableFieldUpdates",
"project": "OPS",
"issue_type": "Bug",
},
StartsAt: time.Now(),
EndsAt: time.Now().Add(time.Hour),
},
},
searchResponse: issueSearchResult{
Total: 1,
Issues: []issue{
{
Key: "OPS-3",
Fields: &issueFields{
Status: &issueStatus{
Name: "Open",
StatusCategory: struct {
Key string `json:"key"`
}{
Key: "open",
},
},
},
},
},
},
issue: issue{
Key: "",
Fields: &issueFields{
Summary: "These issue fields don't match the issue in the search response above",
Description: "If the test checks these values, then it tried to update the fields and it should fail",
},
},
customFieldAssetFn: func(t *testing.T, issue map[string]any) {},
},
} {
tc := tc

Expand Down
Loading