feat(alerting): add Jira alerting provider - #1780
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The Jira resolve path can miss the matching issue due to unbounded/paginated search results, and several error paths omit Jira’s response body, making failures hard to diagnose.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a new Jira alerting provider to Gatus’ alerting subsystem, wiring it into config validation/registration and documenting its configuration in the README.
Changes:
- Introduces
jiraas a new alert type and registers it across alerting/config, provider registry, and config validation. - Implements the Jira provider logic (create issue on trigger; search + transition issue(s) on resolve) with unit tests.
- Documents Jira alerting configuration and options in the README.
File summaries
| File | Description |
|---|---|
| README.md | Adds “Configuring Jira alerts” documentation and config key reference entry. |
| config/config.go | Registers alert.TypeJira in alerting validation. |
| alerting/provider/provider.go | Registers Jira provider in the provider registry and compile-time interface checks. |
| alerting/provider/jira/jira.go | Implements Jira provider config validation + create/resolve (transition) logic. |
| alerting/provider/jira/jira_test.go | Adds unit tests for Jira provider create/resolve/error paths and config overrides. |
| alerting/config.go | Adds Jira *jira.AlertProvider to the alerting config struct. |
| alerting/alert/type.go | Adds new alert type constant TypeJira. |
Review details
Suppressed comments (3)
alerting/provider/jira/jira.go:144
- When searching issues fails, returning only the status code hides Jira's error details (JQL parse errors, auth failures, permission issues). Read and include the response body in the returned error.
if response.StatusCode >= 400 {
return fmt.Errorf("failed to search issues, status: %d", response.StatusCode)
}
alerting/provider/jira/jira.go:175
- When fetching available transitions fails, Jira typically provides useful details in the response body (e.g., missing transition permissions). Include the response body in the error message to aid debugging.
if transitionsResponse.StatusCode >= 400 {
return fmt.Errorf("failed to fetch transitions for %s, status: %d", issueKey, transitionsResponse.StatusCode)
}
alerting/provider/jira/jira.go:206
- When transitioning the issue fails, Jira's response body often includes the reason (invalid transition ID, missing fields, permissions). Include the response body in the error message for easier troubleshooting.
if response.StatusCode >= 400 {
return fmt.Errorf("failed to transition issue %s, status: %d", issueKey, response.StatusCode)
}
- Files reviewed: 7/7 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| jql := fmt.Sprintf("project = %q AND statusCategory != Done ORDER BY created DESC", cfg.ProjectKey) | ||
| response, err := provider.sendRequest(cfg, http.MethodGet, "/rest/api/2/search?jql="+url.QueryEscape(jql), nil) | ||
| if err != nil { |
| if response.StatusCode >= 400 { | ||
| return fmt.Errorf("failed to create issue, status: %d", response.StatusCode) | ||
| } |
|
@ChrisJr404 would you mind looking into copilot's suggestions? I don't have a jira instance I can validate those on, nor am I super familiarwith Jira's API |
Include the Jira response body in create/search/transition error messages so failures like JQL parse errors, auth issues, and invalid transitions are diagnosable. Page through the resolve search results so a matching issue is not missed when the project has more open issues than fit in one response.
|
Done. Pushed a commit that addresses both of Copilot's points:
No live Jira instance needed on your end; the existing unit tests cover the create/resolve/error paths and still pass. |
|
Both of Copilot's points are reasonable:
Neither needs a live Jira to reason about. Want me to push those two changes on top, or would you rather merge as-is and iterate? |
Closes #489.
Adds Jira as a new alerting provider, modeled on the existing GitHub provider like the issue suggested. On trigger it creates an issue in the configured project, and when
send-on-resolvedis set it looks up the matching open issue(s) and moves them through the configured transition (Doneby default) once the alert resolves. Authentication is basic auth with an account email and an API token.Config is minimal to get started:
issue-type(defaultTask) andresolve-transition(defaultDone) are optional. Added unit tests covering create/resolve/error paths and README docs.