Skip to main content

Zephyr Scale API - Automation Results Publisher

Overview

The tool provides an opportunity to update test cases status and publish automation test results into Zephyr Scale Cloud.
Detailed Automation API requests and properties can be found here: Zephyr Scale API

Usage of the tool in the project

Install zephyr-results-publisher library

pip install zephyr-results-publisher

Use the library

from zephyr_results_publisher import publisher

Set environment variable Zephyr Scale ZEPHYR_TOKEN:
How to generate API KEY: Generating API Access Tokens

For UNIX like platforms:

export ZEPHYR_TOKEN=XXXXXXXXX

For Windows platforms:

set ZEPHYR_TOKEN=XXXXXXXXX

To publish automation results into Zephyr Test Cycle root folder

# Zephyr Scale API Access Token. Suggestion: should be provided as environment variable to avoid security issues.
zephyr_token = <ZEPHYR_TOKEN>

# Key name of the Jira project  
project_key = <PROJECT_KEY>

# Absolute path to the report file. E.g. "/Users/user/Project/report/cucumber.json"  
source_report_file = <REPORT_FILE_PATH>
    
# Report format. Possible values: "cucumber", "junit", "behave", "custom"  
report_format = "cucumber"
    
# Automatically create test cases if they are absent in Zephyr Scale. Possible values: true, false  
auto_create_test_cases = "true"    

# Execute
publisher.publish(zephyr_token, project_key, source_report_file, report_format, auto_create_test_cases)

To publish automation results into a specific Zephyr Test Cycle folder and customize Test Cycle properties

# Key name of the Jira project  
project_key = <PROJECT_KEY>

# Absolute path to the report file. E.g. "/Users/user/Project/report/cucumber.json"  
source_report_file = <REPORT_FILE_PATH>
    
# Report format. Possible values: "cucumber", "junit", "behave", "custom".  
report_format = "cucumber"
    
# Automatically create test cases if they are absent in Zephyr Scale. Possible values: "true", "false". Default: "true"   
auto_create_test_cases = "true"    

# Customized test cycle name. Default: "Automated Build"  
test_cycle_name = "Automated Build"

# Set test cycle folder to publish the results. Default: "All test cycles"  
# IMPORTANT: the folder should be already created manually in Zephyr Scale "Test Cycles"  
test_cycle_folder_name = "All test cycles"
    
# Customized test cycle description. Default: ""  
test_cycle_description = "Test Cycle description"

# Set project version. Default: 1  
test_cycle_jira_project_version = 1

# Set test cycle custom fields. E.g {"Sprint": 23}. Default: {}  
test_cycle_custom_fields = {}

publisher.publish_customized_test_cycle(zephyr_token,
                              project_key, 
                              source_report_file, 
                              report_format, 
                              auto_create_test_cases
                              test_cycle_name,
                              test_cycle_folder_name,
                              test_cycle_description,
                              test_cycle_jira_project_version,
                              test_cycle_custom_fields)

IMPORTANT: Publisher tool should be executed after the test report is fully generated.
The best solution would be to create a function in one of the existing *.py files in the test project with @atexit.register annotation. E.g.:

To publish results into Test Cycle root folder use function:

@atexit.register
def publish_report():  
    zephyr_token = os.environ.get("ZEPHYR_TOKEN")
    if zephyr_token is not None:
        project_key = "PROJECT_KEY"  
        source_report_file = "/Users/user/Project/report/cucumber.json"  
        report_format = "behave"   
        auto_create_test_cases = "true"  
        publisher.publish(zephyr_token, project_key, source_report_file, report_format, auto_create_test_cases)

or to publish automation results into a specific Zephyr Test Cycle folder and customize Test Cycle properties:

@atexit.register
def publish_report():
    zephyr_token = os.environ.get("ZEPHYR_TOKEN")
    if zephyr_token is not None:
        project_key = "PROJECT_KEY"
        source_report_file = "report/behave-report.json"
        report_format = "behave"
        auto_create_test_cases = "true"
        test_cycle_name = "Test Cycle Name"
        test_cycle_folder_name = "Already created folder name"
        test_cycle_description = "Test Cycle description"
        test_cycle_jira_project_version = 1
        test_cycle_custom_fields = {}
        publisher.publish_customized_test_cycle(zephyr_token,
                                                project_key,
                                                source_report_file,
                                                report_format,
                                                auto_create_test_cases,
                                                test_cycle_name,
                                                test_cycle_folder_name,
                                                test_cycle_description,
                                                test_cycle_jira_project_version,
                                                test_cycle_custom_fields)

Metadata

Release files for zephyr-results-publisher 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zephyr-results-publisher 0.2.0
File Size Uploaded
zephyr_results_publisher-0.2.0.tar.gz 9.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zephyr-results-publisher 0.2.0
File Interpreter ABI Platform
zephyr_results_publisher-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.9 kB

Release files / zephyr_results_publisher-0.2.0.tar.gz

Download URL zephyr_results_publisher-0.2.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
350c727166e85de3286224cb44d4e77abe2e200c1db6fe6bf62155d75efcfdb9
BLAKE2b-256 checksum
How to use checksums
800bb2f95c7179cef33c4e21b8b0e979d2953feb6108572db967ae18ac98583a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / zephyr_results_publisher-0.2.0-py3-none-any.whl

Download URL zephyr_results_publisher-0.2.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7eef92b6948b45661ca1ec61cef6d000d0a7f0542d17e236f02fbfa9db2b1e1a
BLAKE2b-256 checksum
How to use checksums
aebac04169b968ccd7f0201e7d7dfd7c68dc9cd229ed055016537c09863cd7ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page