Python client for Xray Cloud (GraphQL + REST) with automatic Jira issueId resolution
Project description
xray-cloud-for-jira
Python client for Xray Cloud (GraphQL + REST) with automatic Jira issueId resolution.
Why this package exists
Xray Cloud is not just a classic Jira REST client problem:
- Xray Cloud uses its own authentication model
- GraphQL is the primary API for many operations
- Jira keys and Xray issue IDs are not the same thing
- imports and evidences use separate REST endpoints
This package isolates that complexity in a single reusable Python client.
Main features
- OAuth2 authentication for Xray Cloud using
client_id/client_secret - GraphQL helper with optional list-to-query conversion
- automatic Jira key → Xray issue ID resolution
- support for:
- test retrieval
- test plan retrieval
- test execution retrieval
- test run listing
- test execution creation
- adding tests to a test plan
- test run status updates
- Robot / JUnit / Cucumber imports
- evidence upload
Installation
pip install xray-cloud-for-jira
or with uv:
uv add xray-cloud-for-jira
Package structure
xray-cloud-for-jira/
├── src/xray_cloud_for_jira/
│ ├── __init__.py
│ └── client.py
├── examples/
├── pyproject.toml
├── README.md
├── LICENSE
└── .gitignore
Quick start
1. Environment variables
export XRAY_CLIENT_ID="your-client-id"
export XRAY_CLIENT_SECRET="your-client-secret"
2. Python example
from xray_cloud_for_jira import XrayCloudClient
client = XrayCloudClient(debug=True)
test = client.get_test("DEMO-6")
print(test)
tests = client.get_tests_with_test_plan("DEMO-10")
print(tests)
Explicit connection
from xray_cloud_for_jira import XrayCloudClient
client = XrayCloudClient(
client_id="your-client-id",
client_secret="your-client-secret",
verify_ssl=False,
timeout=30,
debug=False,
)
GraphQL examples
Simple string query
query = '''
query($issueId: String!) {
getTest(issueId: $issueId) {
issueId
jira(fields:["key","summary"])
}
}
'''
result = client.graphql(query, {"issueId": "66925"})
print(result)
Multi-line list query
query = [
"query($issueId: String!) {",
" getTest(issueId: $issueId) {",
' jira(fields:["key","summary"])',
" }",
"}",
]
result = client.graphql(query, {"issueId": "66925"})
Automatic Jira → Xray mapping
One of the most important features of this package is the automatic resolution from a Jira key such as:
DEMO-6
to the Xray internal issue ID required by GraphQL operations.
This lets you work with natural Jira references in your code instead of manually resolving IDs everywhere.
Supported methods
Lookup and search
get_test_id(ticket_ref)get_test_plan_id(ticket_ref)get_test_execution_id(ticket_ref)get_tests_by_jql(jql, limit=10)get_test_plans_by_jql(jql, limit=10)get_test_executions_by_jql(jql, limit=10)
Entity retrieval
get_test(ticket_ref)get_tests_with_test_plan(ticket_ref)get_tests_with_test_execution(ticket_ref)get_test_runs(ticket_ref)
Write operations
create_test_execution(project_key, summary)add_tests_to_test_plan(plan_ref, test_refs)update_test_run_status(run_id, status)
Imports
import_robot_results(file_path, project_key=None)import_junit_results(file_path)import_cucumber_results(file_path)
Evidences
add_evidence_to_test_run(run_id, file_path)
Example: create execution
execution = client.create_test_execution(
project_key="DEMO",
summary="Execution created from xray-cloud-for-jira",
)
print(execution)
Example: add tests to a test plan
result = client.add_tests_to_test_plan(
"DEMO-10",
["DEMO-6", "DEMO-7"],
)
print(result)
Example: import Robot results
result = client.import_robot_results(
"output.xml",
project_key="DEMO",
)
print(result)
Example: add evidence
result = client.add_evidence_to_test_run(
run_id="123456",
file_path="screenshot.png",
)
print(result)
Example: lists the tests of a testplan
tests = client.get_tests_with_test_plan("DEMO-123")
for t in tests["results"]:
print(t)
Error handling philosophy
The client keeps things intentionally simple:
- authentication errors raise HTTP errors
- GraphQL errors are surfaced as assertion failures with the raw
errorspayload - file imports raise
FileNotFoundErrorif the local file is missing - failing imports raise a
RuntimeErrorwith the response payload
SSL note
For local validation or lab environments, verify_ssl=False can be useful.
For production usage, enable certificate verification whenever possible.
Typical use cases
- standalone Python automation
- CI/CD steps importing execution results
- Jira/Xray utility scripts
- higher-level wrappers such as Robot Framework libraries
- future packaging inside a broader QA / TestOps platform
Development install
git clone https://github.com/orenault/xray-cloud-for-jira.git
cd xray-cloud-for-jira
pip install -e .
or with uv:
uv sync
Build
uv build
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xray_cloud_for_jira-0.1.0.tar.gz.
File metadata
- Download URL: xray_cloud_for_jira-0.1.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ea216aab514da95279029b2395b4f36b7b9d34ed8fdbf147d7c59ee675a0345
|
|
| MD5 |
6b62522e46332b27d155fc31d08188a4
|
|
| BLAKE2b-256 |
5cdc685c267e574bbb00c4396d74c5f9e7166bcab0bcdc1336cbc98014800d34
|
File details
Details for the file xray_cloud_for_jira-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xray_cloud_for_jira-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd7de27df07073b69b9f0ab7866e4cf6ec29e46b6ee662993b928b8dafc442a0
|
|
| MD5 |
11f59100e2b4f652fc6bcc555d004ede
|
|
| BLAKE2b-256 |
04021f3c03f728234f18b7c175bf3c7ab38d87fd804281ded88c3676c7bc43f2
|