Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
titlePlease note

Please use the latest version of PowerShell (i.e. >= 6.0) since previous versions had limitations concerning HTTP multipart support.


Table of Contents

Submit results using Xray JSON format

In this example, we'll be making use of Xray's REST API for importing results using Xray's JSON format (more info here: Import Execution Results - REST).

It will create a Test Execution, with fixVersion "v3.0", Revision "123" for Test Environment "Chrome", assigned to the Test Plan "CALC-2208".


Code Block
languagepowershell
titlesubmit_xray.ps1
collapsetrue
try {
 $user = 'admin'
 $pass = 'password'
 $jira_base_url = 'http://yourjiraserverbaseurl'
 $version = 'v3.0'
 $revision = '123'
 $environment = 'Chrome'
 $testplan = 'CALC-2208'


 $pair = "$($user):$($pass)"
 $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
 $basicAuthValue = "Basic $encodedCreds"


$json = @"
{
    "info" : {
        "summary" : "Execution of automated tests for release v1.3",
        "description" : "This execution is automatically created when importing execution results from an external source",
        "version" : "$($version)",
        "revision" : "$($revision)",
        "testEnvironments": ["$($environment)"],
        "testPlanKey" : "$($testplan)"
    },
    "tests" : [
        {
            "testKey" : "CALC-2",
            "start" : "2017-08-30T11:47:35+01:00",
            "finish" : "2017-08-30T11:50:56+01:00",
            "comment" : "Successful execution",
            "status" : "PASS"
        },
        {
            "testKey" : "CALC-73",
            "start" : "2017-08-30T11:47:35+01:00",
            "finish" : "2017-08-30T11:50:56+01:00",
            "comment" : "Unsuccessful execution",
            "status" : "FAIL"
        }
     ]
}
"@


 $uri = "$($jira_base_url)/rest/raven/1.0/import/execution"
 $res = Invoke-WebRequest -Uri $uri -Body $json -Method POST -ContentType "application/json" -Headers @{"Authorization" = $basicAuthValue} }
catch {     
write-host $_.Exception.Message
}

Submit JUnit results

In this example, we'll be making use of Xray's REST API for importing results for JUnit (more info here: Import Execution Results - REST).

...

In this example, we'll be making use of Xray's REST API for importing results for JUnit, namely the multipart endpoint (more info here: Import Execution Results - REST).

...