0

How do I integrate slack notifications from Xray? And can I do it at all? Maybe using webhooks. Red the documentation and didn't find the answer. Thank you!

  • 1. Can you please clarify if you're using Xray on Jira server/datacenter or if it's Xray on Jira cloud? 2. what exactly would be the information you would like to receive (i.e. the contents) and when should it be triggered (i.e.. the trigger condition)? – Sérgio Aug 18 '22 at 16:19
  • Hi Alexander, for us to be able to help you out, can you please clarify the previous questions I left here? thanks – Sérgio Aug 23 '22 at 08:39
  • Just checking if you saw the previous messages so we can be able to help you out – Sérgio Sep 06 '22 at 09:10

1 Answers1

-1

The integration can be done using Jira's built-in Automation capabilities. In your project, go to Project settings > Automation and create an automation rule. You start by defining the trigger, for example based on Test Execution issue being transitioned to a given workflow status, as shown below, or whenever Test Execution issues are created if you prefer.

configuration of trigger

As the rule's action, define a "Send web request" with the following JSON content. We'll send it to a webhook endpoint defined for a Slack app that we need to have (you can create on on the Slack API docs). To get test results information, we may need to use different approaches depending on which Jira deployment type we're using. For example, if we're using Xray on Jira datacenter, then we can use information stored on the "Test Execution Status" custom field that contains counters about the overall test results. If we had Xray cloud, we would need to make a GraphQL request to Xray's API (requires some additional work).

    {
    "blocks": [
        {
            "type": "context",
            "elements": [
                {
                    "type": "mrkdwn",
                    "text": "Test results were reported for project *{{project.name}}*"
                }
            ]
        },
        {
            "type": "context",
            "elements": [
                {
                    "type": "mrkdwn",
                    "text": "{{issue.summary}}"
                }
            ]
        },
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "All tests reported by {{issue.reporter.displayName}} passed. Nothing to worry about."
            },
            "accessory": {
                "type": "image",
                "image_url": "https://docs.getxray.app/s/e1tqew/8402/f0863dd17de361916f7914addff17e0432a0be98/_/images/icons/emoticons/check.png",
                "alt_text": "test results without failures"
            }
        },
        {
            "type": "divider"
        },
        {
            "type": "section",
            "text": {
                "text": "Test Execution details, including its Test Runs",
                "type": "mrkdwn"
            },
            "fields": [
     
                 {
                    "type": "mrkdwn",
                    "text": "*Test Execution*\n<{{issue.url}}|{{issue.key}}>"
                  }, {
                    "type": "mrkdwn",
                      "text": "*Version*\n{{issue.fixVersions.name}}"
                  }, {
                    "type": "mrkdwn",
                      "text": "*Revision*\n{{issue.Revision}}"
                  }, {
                    "type": "mrkdwn",
                      "text": "*Test Environment(s)*\n{{issue.Test Environments}}"
                  }, {
                    "type": "mrkdwn",
                      "text": "*Test Plan*\n<{{baseUrl}}/browse/{{issue.Test Plan}}|{{issue.Test Plan}}>"
                  }, {
                    "type": "mrkdwn",
                      "text": "*Total tests*\n{{Test Execution Status.count}}"
                  }, {
                    "type": "mrkdwn",
                      "text": "*Passed tests*\n{{Test Execution Status.statuses.get(0).statusCount}}"
                  }, {
                    "type": "mrkdwn",
                      "text": "*Failed tests*\n{{Test Execution Status.statuses.get(1).statusCount}}"
                  }, {
                    "type": "mrkdwn",
                      "text": "*Other tests*\n{{#=}}{{Test Execution Status.count}} - {{Test Execution Status.statuses.get(0).statusCount}} - {{Test Execution Status.statuses.get(1).statusCount}}{{/}}"
                  }
               
            ]
        }
    ]
 }

configuration of web request

As reference, there are tutorials showcasing precisely the integration with Slack, with additional information that may be useful.

Sérgio
  • 1,777
  • 2
  • 10
  • 12
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/34927035) – ChrisGPT was on strike Aug 31 '23 at 18:41