Skip to main content

File Jira Bugs Automatically for Failed Tests

With the Jira webhook template, TestingBot creates a Bug issue in your Jira Cloud project whenever a test fails. The issue summary contains the test result and name, and the description links straight to the test details page with its video, logs and screenshots.

The template posts to the Jira Cloud REST API v3 and authenticates with Basic Auth. TestingBot also offers a native Jira integration for manually reporting bugs from test results; the webhook described here is the fully automated alternative.

Prerequisites

You need an Atlassian API token and a few details about your Jira site:

  1. Create an Atlassian API token and copy it. The token is paired with your Atlassian account email for Basic Auth.
  2. Note your Jira site domain: the webhook URL is https://YOUR-DOMAIN.atlassian.net/rest/api/3/issue with your own domain filled in.
  3. Note the project key of the project where issues should be created, for example QA, and make sure the project has a Bug issue type (or another issue type you want to use).

The account that owns the API token needs permission to create issues in that project.

Set up the webhook in TestingBot

  1. Log in to the TestingBot member area and open the Webhooks page under Integrations.
  2. Click Create webhook and give it a name, for example Jira bugs.
  3. Under Start from a template, pick the Jira tile. This prefills the URL, the POST method and the payload below.
  4. In the URL, replace YOUR-DOMAIN with your Jira site domain.
  5. In the Authorization tab, choose Basic Auth, enter your Atlassian account email as the username and the API token as the password.
  6. In the Body tab, replace YOUR_PROJECT_KEY with your project key, and change the issuetype name if your project does not use Bug.
  7. Set the trigger to failures only, so an issue is only filed when a test fails. Optionally narrow it down with a test type or a name filter such as regression_*.
  8. Click Create webhook at the bottom of the form to save the configuration.

Template payload

The Jira template sends this JSON body. Replace YOUR_PROJECT_KEY with the key of your Jira project; the {{...}} tokens are substituted with test values at delivery time and are documented on the built-in variables page.

{
  "fields": {
    "project": { "key": "YOUR_PROJECT_KEY" },
    "issuetype": { "name": "Bug" },
    "summary": "Test {{TEST_STATUS}}: {{TEST_NAME}}",
    "description": {
      "type": "doc",
      "version": 1,
      "content": [
        {
          "type": "paragraph",
          "content": [
            {
              "type": "text",
              "text": "Test {{TEST_NAME}} finished with status {{TEST_STATUS}} on {{PLATFORM}}. View it at {{TEST_URL}}"
            }
          ]
        }
      ]
    }
  }
}

The description uses the Atlassian Document Format (ADF), which the Jira Cloud REST API v3 requires. Everything stays editable: you can add fields such as labels or priority, or extend the description with more paragraphs and variables, as long as the ADF structure stays valid.

Test it

Click Test Webhook in the form to send a sample request with placeholder test values. The response panel shows the HTTP status, duration, headers and body returned by Jira; a successful request returns a 201 status with the new issue key in the body, and the issue appears in your project.

If no issue is created, check these common causes:

  • The Basic Auth credentials are wrong: use your Atlassian email as username and the API token (not your password) as password. Jira responds with a 401 status in that case.
  • The project key is wrong or still set to the YOUR_PROJECT_KEY placeholder, or the account lacks create permission; Jira responds with a 400 or 403 status and an error message in the body.
  • The issue type Bug does not exist in the project, or a required custom field is missing from the payload.
Was this page helpful?
Last updated