Page History
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
try { $client_id = 'DA2258616A5944198E9BE44A9A000000' $client_secret = '5bae1aa5b49e5d263781da54ba55cc7deebd7840c68fe2fdfd2a077768000000' $version = 'v1.0' $revision = '123' $environment = 'chrome' $testplan = 'XT-168' $jira_base_url = 'https://xray.cloud.xpand-itgetxray.comapp/api/v1v2' $json = @" { "client_id": "$($client_id)", "client_secret": "$($client_secret)" } "@ $uri = "$($jira_base_url)/authenticate" $res = Invoke-WebRequest -Uri $uri -Body $json -Method POST -ContentType "application/json" $token = $res -replace '"','' # write-host $token $xrayjson = @" { "info" : { "summary" : "Execution of automated tests for release v3.0", "description" : "This execution is automatically created when importing execution results from an external source", "version" : "$($version)", "revision" : "$($revision)", "testEnvironments": ["$($environment)"], "testPlanKey" : "$($testplan)" }, "tests" : [ { "testKey" : "XT-165", "start" : "2017-08-30T11:47:35+01:00", "finish" : "2017-08-30T11:50:56+01:00", "comment" : "Successful execution", "status" : "PASS" }, { "testKey" : "XT-166", "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)/import/execution" $res = Invoke-WebRequest -Uri $uri -UseBasicParsing -ContentType "application/json" -Body $xrayjson -Method POST -Headers @{"Authorization" = "Bearer $token"} write-host $res } catch { write-host $_.Exception.Message write-host $_.Exception } |
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
@echo off set client_id="DA2258616A5944198E9BE44A9A000000" set client_secret="5bae1aa5b49e5d263781da54ba55cc7deebd7840c68fe2fdfd2a077768000000" set report_file="xray.json" set jira_base_url="https://xray.cloud.xpand-itgetxray.comapp/api/v2" for /f %%i in ('curl -H "Content-Type: application/json" -X POST --data "{ \"client_id\": \"%client_id%\",\"client_secret\": \"%client_secret%\" }" https://xray.cloud.xpand-itgetxray.comapp/api/v2/authenticate') do set token=%%i rem echo %token% curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer %token%" --data @"%report_file%" "%jira_base_url%/import/execution" |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
try { $client_id = 'DA2258616A5944198E9BE44A9A000000' $client_secret = '5bae1aa5b49e5d263781da54ba55cc7deebd7840c68fe2fdfd2a077768000000' $project_key = 'XT' $report_file = 'junit.xml' $jira_base_url = 'https://xray.cloud.xpand-itgetxray.comapp/api/v2' $json = @" { "client_id": "$($client_id)", "client_secret": "$($client_secret)" } "@ $uri = "$($jira_base_url)/authenticate" $res = Invoke-WebRequest -Uri $uri -Body $json -Method POST -ContentType "application/json" $token = $res -replace '"','' #write-host $token $fileContent = Get-Content -Path $report_file -Raw $uri = "$($jira_base_url)/import/execution/junit?projectKey=$($project_key)" $res = Invoke-WebRequest -ContentType "text/xml" -Uri $uri -Body $fileContent -Method POST -Headers @{"Authorization" = "Bearer $token"} write-host $res } catch { write-host $_.Exception.Message } |
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
@echo off set client_id="DA2258616A5944198E9BE44A9A000000" set client_secret="5bae1aa5b49e5d263781da54ba55cc7deebd7840c68fe2fdfd2a077768000000" set project_key="XT" set report_file="junit.xml" set jira_base_url="https://xray.cloud.xpand-itgetxray.comapp/api/v2" for /f %%i in ('curl -H "Content-Type: application/json" -X POST --data "{ \"client_id\": \"%client_id%\",\"client_secret\": \"%client_secret%\" }" https://xray.cloud.xpand-itgetxray.comapp/api/v2/authenticate') do set token=%%i rem echo %token% curl -H "Content-Type: text/xml" -X POST -H "Authorization: Bearer %token%" --data @"%report_file%" "%jira_base_url%/import/execution/junit?projectKey=%project_key%" |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
try { $client_id = 'DA2258616A5944198E9BE44A9A000000' $client_secret = '5bae1aa5b49e5d263781da54ba55cc7deebd7840c68fe2fdfd2a077768000000' $project_key = 'XT' $report_file = 'junit.xml' $infoFile = "issueFields.json" $jira_base_url = 'https://xray.cloud.xpand-itgetxray.comapp/api/v2' $json = @" { "client_id": "$($client_id)", "client_secret": "$($client_secret)" } "@ $uri = "$($jira_base_url)/authenticate" $res = Invoke-WebRequest -Uri $uri -Body $json -Method POST -ContentType "application/json" $token = $res -replace '"','' # write-host $token $multipartContent = New-Object System.Net.Http.MultipartFormDataContent $FsMode = [System.IO.FileMode]::Open $FsAccess = [System.IO.FileAccess]::Read $FsSharing = [System.IO.FileShare]::Read $FileStream = New-Object System.IO.FileStream($report_file, $FsMode, $FsAccess, $FsSharing) # additional information for the Test Execution issue; it follows the syntax of Jira REST API for updating fields $info = @" { "fields": { "summary": "Test Execution for junit Execution", "project": { "key": "$($project_key)" }, "issuetype": { "name": "Test Execution" }, "components" : [ { "name":"ui" }, { "name":"core" } ] } } "@ $fileHeader = New-Object System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") $fileHeader.Name = '"info"' $fileHeader.FileName = $infoFile $stream = [IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($info)) $infoContent = New-Object System.Net.Http.StreamContent($stream) $infoContent.Headers.ContentDisposition = $fileHeader $infoContent.Headers.ContentType = [System.Net.Http.Headers.MediaTypeHeaderValue]::Parse("application/octet-stream") $multipartContent.Add($infoContent) <# # in case you want to read the Json metainformation from a file instead $FsMode = [System.IO.FileMode]::Open $FsAccess = [System.IO.FileAccess]::Read $FsSharing = [System.IO.FileShare]::Read $FileStream = New-Object System.IO.FileStream($infoFile, $FsMode, $FsAccess, $FsSharing) $fileHeader = New-Object System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") $fileHeader.Name = "info" $fileHeader.FileName = $infoFile $fileContent = New-Object System.Net.Http.StreamContent($FileStream) $fileContent.Headers.ContentDisposition = $fileHeader $fileContent.Headers.ContentType = [System.Net.Http.Headers.MediaTypeHeaderValue]::Parse("application/json") $multipartContent.Add($fileContent) #> $fileHeader = New-Object System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") $fileHeader.Name = '"results"' $fileHeader.FileName = $report_file $fileContent = New-Object System.Net.Http.StreamContent($FileStream) $fileContent.Headers.ContentDisposition = $fileHeader $fileContent.Headers.ContentType = [System.Net.Http.Headers.MediaTypeHeaderValue]::Parse("application/xml") $multipartContent.Add($fileContent) $uri = "$($jira_base_url)/import/execution/junit/multipart" $res = Invoke-WebRequest -Uri $uri -UseBasicParsing -Body $multipartContent -Method POST -Headers @{"Authorization" = "Bearer $token"} write-host $res } catch { write-host $_.Exception.Message write-host $_.Exception } |
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
@echo off set client_id="DA2258616A5944198E9BE44A9A000000" set client_secret="5bae1aa5b49e5d263781da54ba55cc7deebd7840c68fe2fdfd2a077768000000" set report_file="junit.xml" set project_key="XT" set info_file="issueFields.json" set jira_base_url="https://xray.cloud.xpand-itgetxray.comapp/api/v2" for /f %%i in ('curl -H "Content-Type: application/json" -X POST --data "{ \"client_id\": \"%client_id%\",\"client_secret\": \"%client_secret%\" }" https://xray.cloud.xpand-itgetxray.comapp/api/v2/authenticate') do set token=%%i rem echo %token% curl -X POST -H "Content-Type: multipart/form-data" -H "Authorization: Bearer %token%" -F info=@"%info_file%" -F results=@"%report_file%" "%jira_base_url%/import/execution/junit/multipart" |
...