Skip to content

Commit 6add394

Browse files
guolauragog
andauthored
feat: update Jira webhook info and add example with issue priority set based on check tags (#1292)
Co-authored-by: ragog <[email protected]>
1 parent 8c356bf commit 6add394

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

site/content/docs/alerting-and-retries/webhooks.md

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ exports.handler = async function (context, event, callback) {
346346

347347
## Jira
348348

349-
A webhook can be used to create a new issue on Jira via the [Jira API](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/), for example in the case of a previously passing check that switches to failing state.
349+
A webhook can be used to create a new issue on Jira via the [Jira API](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/), for example in the case of a previously passing check that switches to failing state.
350350

351-
We will be creating a POST request to `{{JIRA_INSTANCE_URL}}/rest/api/2/issue`, where the content of your `JIRA_INSTANCE_URL` environment variable would look something like `https://your-jira-instance-name.atlassian.net`.
351+
We will be creating a POST request to `{{JIRA_INSTANCE_URL}}/rest/api/3/issue`, where the content of your `JIRA_INSTANCE_URL` environment variable would look something like `https://your-jira-instance-name.atlassian.net`.
352352

353353
The required headers will be:
354354

@@ -360,20 +360,55 @@ Content-Type: application/json
360360

361361
An example body could look as follows:
362362

363-
```json
363+
``` {title="Webhook Body"}
364364
{
365365
"fields": {
366-
"description": "{{RESULT_LINK}}",
366+
"description": { // your Jira issue description, using Atlassian Document Format (ADF)
367+
"version": 1,
368+
"type": "doc",
369+
"content": [
370+
{
371+
"type": "paragraph",
372+
"content": [
373+
{
374+
"type": "text",
375+
"text": "View check result",
376+
"marks": [
377+
{
378+
"type": "link",
379+
"attrs": {
380+
"href": "{{RESULT_LINK}}"
381+
}
382+
}
383+
]
384+
}
385+
]
386+
}
387+
]
388+
},
367389
"issuetype": {
368390
"id": "10001" // your Jira issue type id
369391
},
370392
"labels": [
371393
"needs_investigation"
372394
],
395+
"priority": { // dynamically set the issue priority, based on the check's tags
396+
"id": {{#contains TAGS "P1"}} "1"
397+
{{else}} {{#contains TAGS "P2"}} "2"
398+
{{else}} {{#contains TAGS "P3"}} "3"
399+
{{else}} {{#contains TAGS "P4"}} "4"
400+
{{else}} {{#contains TAGS "P5"}} "5"
401+
{{else}} "3"
402+
{{/contains}} {{/contains}} {{/contains}} {{/contains}} {{/contains}}
403+
},
373404
"project": {
374405
"key": "ABC" // your Jira project key
375406
},
376407
"summary": "{{ALERT_TITLE}}"
377408
}
378409
}
379410
```
411+
412+
For full details on creating issues via the Jira API, see [Atlassian's documentation for this endpoint](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post).
413+
414+
You can also use version 2 of the Jira API (i.e. `{{JIRA_INSTANCE_URL}}/rest/api/2/issue`). The only difference is that version 2 does not support [Atlassian Document Format (ADF)](https://developer.atlassian.com/cloud/jira/platform/apis/document/structure/).

0 commit comments

Comments
 (0)