Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Importing JUnit result xml into existing sub test execution [xray] with github action / REST API

Stefan Salzl
Community Champion
March 11, 2022 edited

Hi folks,

This will be a long-red πŸ™ˆπŸ™ˆ

This is kind of a tricky experiment (at least for me) I am trying to build. I would like to build kind of a DevOps pipeline especially the testing part and also automating the test result reporting back in Jira (Xray), Jira project is connected to my Github repo. Here comes my plan:

  • LetΒ΄s say we have a UserStory "ABC-1", 2 xray generic test cases linked to UserStory (test cases have keys "ABC-2", "ABC-3")
  • the whole pipeline should run on PR
    • in Jira context: created an automation rule that creates a "sub test execution" 
    • in github: configured github action yaml that action only executes on event PullRequest
  • when PR is created
    • in Jira: Sub Test Execution is created (key "ABC-4") within the user Story (ABC-1)
    • github: action starts, runs tests and generates test-result.xml

 

Here comes the problem:

I was able to import the test-result.xml via cURL which generates a standard Test Execution. Even it pays into my coverage of the UserStory (test cases are mapped correctly) I would like to have the test execution as a Sub Test Execution within the UserStory as it is automatically "linked" to the Story and for better traceability.

 

My questions:

  • If github could get the information of which key was generated in the jira automation rule (ABC-4) I could import the test result file to this issue. Does anyone know how this could be done? (especially as the action in github is starting at the same time)
  • If this is not possible could I create the Sub Test Execution out of my github action (guess this should also be possible with cURL similar to how I import test-result file). The question in this case is:
    • How could I get the parent key of my UserStory to tell the API where the Sub Test Execution should be created? (mainly several items in my repo contain of the issue key in order to have those things linked. So the branch, the commits and also the PR will start with the issue key of the story ABC-1). Could I "extract" the issue key from the PR description?

 

Thanks in advance for any helpful feedback.

 

Best
Stefan

2 answers

1 accepted

0 votes
Answer accepted
Stefan Salzl
Community Champion
March 13, 2022

HELL YEAH!!! solved it πŸ’ͺ

I left out A4J to create sub test execution. everything done now in the github action.

0 votes
Mauro Juarez
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 24, 2022

@Stefan Salzl  Would you mind to share an example of the curl you used? I have tried something like this but have not succed yet

 

https://OURDOMAIN/rest/raven/rest/raven/2.0/import/execution/junit?projectKey=OURPROJECT

Stefan Salzl
Community Champion
March 24, 2022

Sure. My curl call looks as follows (keep in mind IΒ΄m working in cloud environment):

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

 

I got aware that your call consits of "/rest/raven" twice. As far as I got it itΒ΄s only /rest/raven/2.0/...

In case this still doesnΒ΄t solve the problem try to use as described in following link with v1:
https://docs.getxray.app/display/XRAY/Import+Execution+Results+-+REST#ImportExecutionResultsREST-JUnitXMLresults

Hope I could give some helpful input.

Looking forward to your feedback.

 

Best
Stefan

Suggest an answer

Log in or Sign up to answer