Skip to content

Jira Issue Handler

Ondřej Gajdušek edited this page Jul 23, 2025 · 1 revision

Jira Issue Handler

The Jira issue handler (jira.py) is currently the only implemented handler and provides comprehensive functionality for managing Jira issues.

Core Functions

is_open_jira

Checks if a specific Jira issue is open by consulting cached data or calling the Jira REST API.

Logic:

  • Issues with status in JIRA_OPEN_STATUSES are considered open
  • Issues with status in JIRA_CLOSED_STATUSES and resolution in JIRA_WONTFIX_RESOLUTIONS are considered open (not fixed yet)
  • Issues not in closed statuses and not in "Testing" status are considered open

should_deselect_jira

Tests are deselected if the issue status is in JIRA_CLOSED_STATUSES and resolution is in JIRA_WONTFIX_RESOLUTIONS

are_all_jira_open

Checks if all Jira issues in a list are open.

are_any_jira_open

Checks if any Jira issue in a list is open.

add_comment_on_jira

Adds comments to Jira issues and optionally updates labels.

Authentication

  • Uses Bearer token authentication with settings.jira.api_key
  • Supports rate limiting with automatic retries

Data Structure

The collected data follows this structure:

{
    "SAT-12345": {
        "data": {
            "key": "SAT-12345",
            "summary": "Issue summary",
            "status": "In Progress",
            "resolution": "",
            "labels": ["bug", "high-priority"],
            "fixVersions": ["6.14.0"],
            "is_open": true,
            "is_deselected": false,
            "dupe_data": null
        },
        "used_in": [
            {
                "filepath": "tests/foreman/ui/test_sync.py",
                "lineno": 124,
                "testcase": "test_positive_sync_custom_ostree_repo",
                "component": "Repositories"
            }
        ]
    }
}

Jira Status Constants

The handler uses predefined constants for status checking:

  • Open Statuses: "New", "Backlog", "Refinement", "To Do", "In Progress", "Review", "Release Pending - Upstream"
  • Closed Statuses: "Release Pending", "Closed"
  • Testing Status: "Testing"
  • Won't Fix Resolutions: "Obsolete"

Doc fields, Pytest options, and Jira comments

BlockedBy and Verifies doc fields

  • BlockedBy: If the issue is open, the test will be skipped/deselected. Override behavior with --blocked-by false.
  • Verifies: Used with --verifies-issues pytest option.

--verifies-issues and --blocked-by pytest options.

  • --verifies-issues: Comma-separated list of Jira issues to collect tests matching the Verifies testimony marker. If no issue is provided, all tests with the Verifies testimony marker will be selected.
  • --blocked-by: Comma-separated list of Jira issues to collect tests matching the BlockedBy testimony marker. If no issue is provided, all tests with the BlockedBy testimony marker will be processed and deselected if any issue is open.

Jira comments

  1. Add a Verifies or BlockedBy doc field to the test, mapping it to a Jira RFE/Bug. 2. For example, :Verifies: SAT-25230 or :BlockedBy: SAT-24796. For BlockedBy, the test will be collected only if the corresponding Jira issue is in the Review (ON_QA) state. This behavior can be overridden by using the --blocked-by SAT-25230 option.
  2. Set ENABLE_COMMENT to true in jira.yaml configuration file.
  3. Use the --jira-comments pytest option.

Note:

  • To prevent accidental usage of this functionality, the user is required to perform both steps 2 and 3.
  • By default, the comment will be added on issues in "Review" and "Release Pending" state, but this could be overridden by setting issue_status in jira.yaml.

Configuration

The Jira handler requires configuration in settings.jira:

  • url: Jira instance URL
  • api_key: API key for authentication
  • cache_file: Path to cache file
  • cache_ttl_days: Cache TTL in days
  • comment_type: Type of comments to add
  • comment_visibility: Comment visibility setting
  • enable_comment: Whether to enable comment functionality