Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,368,011
Community Members
 
Community Events
168
Community Groups

how to import junit xml file using Curl command ?

I'm working on importing Junit XML file that i generate with my tool Cypress , and i looking for importing all test cases insides ti Jira Xray by using command CURL 

 

I tried so many input like : 

curl -H "Content-Type: multipart/form-data" -u user:pwd -F "file=@test-results.xml" https://jira.fr/rest/raven/1.0/import/execution/junit?projectKey={somekey}

curl -H "Content-Type: multipart/form-data" -u user:pwd -F "file=@test-results.xml" https://jira.fr/rest/raven/1.0/import/execution/junit/multipart?projectKey={somekey}

curl -H "Content-Type: multipart/form-data" -u user:pwd -F "file=@test-results.xml" https://jira.fr/rest/raven/1.0/import/execution/junit?testExecKey={somekey}


curl -H "Content-Type: multipart/form-data" -u user:pwd -F "file=@test-results.xml" https://jira.fr/rest/raven/1.0/import/execution/junit/multipart?projectKey={somekey}&testExecKey{somekey}

 

 

I got always those responses : 

{"error":"org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found"}

{"error":"The Test Execution info file is required."}

 

 

is there new methode to make that works please ?

 

 

1 answer

0 votes
Stefan Salzl Community Leader Sep 23, 2022

Hi @Mahmoud Letaief and welcome to the community,

multipart import takes an xml with a json.

Did you try to use „Content-Type: text/xml“?

Best
Stefan

yes , i did . It returns nothing . and when i go to my Test Excution Task in Jira , i find that any tests was imported .

 

this my command :

curl -H "Content-Type: text/xml" -u user:pwd -F "file=@test-results.xml" https://jira.fr/rest/raven/1.0/import/execution/junit?testExecKey=SC-{someKey}

Stefan Salzl Community Leader Sep 26, 2022

Hi @Mahmoud Letaief ,

it seems your call is missing the method (POST). This is a call I used  succeessfully in the past:

curl -H "Content-Type: text/xml" -X POST \
-H "Authorization: Bearer ${{ secrets.XRAY_TOKEN }}" \
--data @"./cypress/test-results.xml" https://xray.cloud.getxray.app/api/v2/import/execution/junit?testExecKey=${key}

 

Best
Stefan 

Hi @Mahmoud Letaief 

I have to add 2 things:

  • even though I was able to manage to import test results I´m a dev/technical rookie. So it´s not my daily business to read xml but I try to find information with documentation
  • I mainly use cloud version so I could not directly test things on server =S

 

In reference to your xml:
according to this documentation page there is a <testsuites> tag wrapped around <testsuit>

<?xml version="1.0" ?>
<testsuites>
    <testsuite errors="0" failures="0" id="0" name="my test suite" tests="1">
        <testcase classname="some.class.name" name="Test1" time="123.345000"/>
    </testsuite>
</testsuites>

 

Which test framework/reporter are u using? How is the xml-file generated?

 

Furthermore:
If you send reports (like verbose output) make sure to delete passwords/plain use names/Tokens in order to keep security level of your system.

Best
Stefan

Stefan Salzl Community Leader Oct 03, 2022

Hi @Mahmoud Letaief 

any update?

Best
Stefan

Suggest an answer

Log in or Sign up to answer