Forum Discussion

antonius2003's avatar
antonius2003
Regular Visitor
2 years ago

Upload test results including info for a testrun (Curl and Python)

Hi,

I want to upload test results to Zephyr Scale for Jira server using the Rest API automation/execution/<projectKey>.

I can create a cycle and upload test results successfully, but the test cycle info are not applied to the test run in Zephyr Scale.

I tried both Curl and Python, but both failed to upload the test cycle info.

# Curl

curl -X POST "https://<Jira Server>/rest/atm/1.0/automation/execution/<projectKey>?autoCreateTestCases=true" -H "Authorization: Bearer <Jira Token>" -F 'testCycle="{\"name\":\"Full regression\",\"description\":\"Any additional description can be added here.\",\"customFields\":{\"Build Number\":20}}";type=application/json' -F "file=@demo_output.zip"
{"testCycle":{"id":141065,"key":"<projectKey>-C159","url":"https://<Jira Server>/secure/Tests.jspa#/testPlayer/<projectKey>-C159"}}

 

# Python

import os
from json import dumps
import requests

session = requests.Session()
session.verify = False
baseURL = "https://<jira server>/rest/atm/1.0/automation/execution/<projectKey>?autoCreateTestCases=True"

testCycle = {
    "name": "Full regression",
    "description": "Any additional description can be added here.",
    "customFields": {
        "Build Number": 20
    }
}
file='demo_output.zip'
files = {
    'testCycle': (None, dumps(testCycle), 'application/json'),
    'file': (os.path.basename(file), open(file, 'rb'), 'application/zip')
}
headers={"Authorization": "Bearer <Jira token>"}
response = session.post(baseURL,files=files,headers=headers)

 

Does somebody has a solution or a working example to this in Curl and Python? Thanks.

 

Regards,

Antonius

No RepliesBe the first to reply