Skip to main content

Automating Jira ticket creation for test failures using TestDriver CLI and Jira GitHub Actions

This guide explains how to integrate the TestDriver CLI with the Jira GitHub Action to automatically create a Jira ticket whenever a TestDriver test fails. This workflow ensures that test failures are tracked in Jira, enabling teams to address issues promptly.

Workflow overview

1

Run Tests with TestDriver CLI

Use the TestDriver CLI with the —headless flag to execute your test suite in a headless environment.
2

Check for Test Failures

Capture the test results and determine if any tests failed.
3

Create a Jira Ticket

Use the Jira GitHub Action to create a new ticket for each test failure, including relevant details such as the test name, failure reason, and logs.

Prerequisites

  1. TestDriver API Key: Store your API key as a GitHub secret (for example, TD_API_KEY).
  2. Jira API Token: Generate an API token from your Jira account and store it as a GitHub secret (for example, JIRA_API_TOKEN).
  3. Jira Base URL: Your Jira instance URL (for example, https://yourcompany.atlassian.net).
  4. Jira Project Key: The key of the Jira project where tickets will be created (for example, TEST).
  5. TestDriver CLI: The TestDriver CLI must be installed and configured in your workflow.

GitHub Actions workflow

Here’s a complete workflow that integrates TestDriver and Jira:

Workflow File:

.github/workflows/testdriver-jira.yaml

Workflow steps explained

1. Run Tests with TestDriver CLI

This step runs the TestDriver CLI with the testdriver/test.yaml file.
testdriver/test.yaml

2. Check for test failures

This step checks the exit code and success status from the TestDriver CLI run. If the tests failed, it sets an environment variable (failure=true) to trigger the Jira ticket creation step and prepares the output file for the Jira ticket.
testdriver/test.yaml

3. Create a Jira ticket

If any tests failed, the create-jira-ticket job uses the atlassian/gajira-create action to create a new Jira ticket. The ticket includes:
  • Summary: A brief description of the failure with repository information.
  • Description: Detailed information about the failure, including repository details, workflow run links, and the captured test output.
testdriver/test.yaml

Secrets configuration

Add the following secrets to your GitHub repository:
  1. TD_API_KEY: Your TestDriver API key.
  2. JIRA_API_TOKEN: Your Jira API token.
  3. JIRA_BASE_URL: Your Jira instance URL (for example, https://yourcompany.atlassian.net).
  4. JIRA_USERNAME: Your Jira account email.