{"id":10144,"library":"pytest-jira-xray","title":"Pytest JIRA XRAY Plugin","description":"pytest-jira-xray is a pytest plugin that facilitates integration of test results with Atlassian JIRA's XRAY Test Management tool. It allows users to export pytest test results to XRAY JSON format or directly upload them to JIRA, associating tests with JIRA issues and updating test plans/executions. The current version is 0.9.3, and it appears to be actively maintained with releases tied to new features or bug fixes.","status":"active","version":"0.9.3","language":"en","source_language":"en","source_url":"https://github.com/e2e-vision/pytest-jira-xray","tags":["pytest","jira","xray","testing","integration","test management"],"install":[{"cmd":"pip install pytest-jira-xray","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"This is a pytest plugin; pytest is a peer dependency required for its functionality.","package":"pytest","optional":false},{"reason":"Used for interacting with the Jira API for test management operations.","package":"jira","optional":false}],"imports":[{"note":"While not importing a specific class from the plugin, users interact with it primarily through pytest markers, e.g., @pytest.mark.jira(key='TEST-123').","symbol":"pytest.mark","correct":"import pytest"}],"quickstart":{"code":"# my_test.py\nimport pytest\n\n@pytest.mark.jira(key='TP-100', test_key='TEST-456')\ndef test_example_success():\n    assert True\n\n@pytest.mark.jira(key='TP-100', test_key='TEST-457')\ndef test_example_failure():\n    assert False\n\n# pytest.ini\n# [pytest]\n# jira-url = https://your-jira-instance.com\n# jira-user = your-username\n# jira-password = your-password\n\n# Run from terminal:\n# export JIRA_URL='https://your-jira-instance.com'\n# export JIRA_USER='your-username'\n# export JIRA_PASSWORD='your-password'\n# pytest --xray-json=xray_report.json --jira-url \"${JIRA_URL}\" --jira-user \"${JIRA_USER}\" --jira-password \"${JIRA_PASSWORD}\" --testplan-key \"TP-100\" --testexecution-key \"TP-EXEC-123\" --upload-xray-results","lang":"python","description":"This quickstart demonstrates creating a test file with JIRA markers and running pytest to generate an XRAY JSON report and upload results to a specified Test Plan/Execution. Authentication details (URL, user, password) can be provided via command-line arguments, environment variables, or configured in `pytest.ini`. For security, using environment variables for sensitive data is recommended."},"warnings":[{"fix":"Be mindful of the precedence order. For CI/CD, environment variables are often preferred for security and flexibility. For local development, `pytest.ini` can be convenient.","message":"Authentication details (JIRA URL, user, password) can be provided via command-line arguments, environment variables (JIRA_URL, JIRA_USER, JIRA_PASSWORD), or `pytest.ini`. Command-line arguments take precedence over environment variables, which take precedence over `pytest.ini`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you include the appropriate flag (`--testplan-key <KEY>` or `--testexecution-key <KEY>`) with your `pytest` command when using `--upload-xray-results`.","message":"When uploading results to a new or existing Test Execution, you must provide either `--testplan-key` to create a new execution under that plan, or `--testexecution-key` to update an existing execution.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the official pytest-jira-xray documentation and XRAY API documentation if you encounter unexpected errors, especially when interacting with different JIRA/XRAY hosting types. Ensure your JIRA instance and XRAY plugin are up-to-date.","message":"The plugin relies on specific XRAY API endpoints. Differences between XRAY Cloud and XRAY Data Center/Server versions can sometimes cause unexpected behavior, although the plugin generally attempts to abstract these.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Verify your JIRA_URL, JIRA_USER, and JIRA_PASSWORD (or corresponding CLI arguments/pytest.ini entries) are correct and that the user has necessary permissions in JIRA and XRAY. Test credentials separately if possible.","cause":"Incorrect JIRA URL, username, or password provided. The credentials do not have permission to access JIRA or the XRAY API.","error":"Jira Xray API Error: 401 Unauthorized"},{"fix":"If you want to generate a JSON report, add `--xray-json=<path/to/report.json>`. If you are uploading directly to Jira and don't need a local JSON file, you still need to ensure `--upload-xray-results` is used correctly with JIRA credentials and test execution details.","cause":"You are trying to run pytest-jira-xray without specifying an output file for the XRAY JSON report or explicitly disabling JSON output when uploading results directly.","error":"Error: the following arguments are required: --xray-json"},{"fix":"Double-check the Test Plan key for typos or ensure that the Test Plan actually exists in your JIRA instance and is accessible to the provided JIRA user.","cause":"The Test Plan key provided with `--testplan-key` does not correspond to an actual Test Plan in JIRA.","error":"XRAY: The Test Plan with key 'XXX-YYY' does not exist."},{"fix":"Verify that your test methods are uniquely mapped to XRAY Test Cases via the `@pytest.mark.jira(test_key='TEST-XXX')` marker. If you're using Test Plans, ensure the test cases are correctly associated within the plan.","cause":"This usually happens when trying to update test cases in a Test Execution where the link between the test method and XRAY Test Case is already established differently or there's a conflict in how tests are mapped.","error":"Cannot assign a test case key 'TEST-XXX' to a test method because it already exists in a different test execution."}]}