Forums

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

How to get test plan from an test execution using the API?

Magnus
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!
September 25, 2024

I’m trying to automate reporting of test case result to our JIRA.

I’m able to do this, via the XRAY API when having an test plan reference as an input.
I get the test execution, with “/rest/raven/1.0/api/testplan/{testplan}/testexecution” and in the next step getting existing tests with “/rest/raven/1.0/api/testplan/{testplan}/test”. Now I connect existing tests with our results and upload them with “/rest/raven/2.0/import/execution”.

The problem is that need to start with an test execution instead and from there get test plan.

When opening the web page for the test execution “https://xxx/browse/XXXX_XXX-41825” there is an field in the top that refers to the Test Plan but how can I get this information using the API?

I have tried to open the page with curl but and locate the data but that does not work, it’s not there in the output. I also looked at the traffic in the browser to see who this data is fetched, without any luck. It is already part of the initial reply.

Is there an API I can use?

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Florian Bonniec
Community Champion
September 25, 2024

Hi @Magnus 

 

You can use the JIRA rest endpoint.

BASE_URL/rest/api/2/issue/ISSUE_KEY_TEST_EXEC

You will have to only query for the custom field named Test Plan using the field ID.

https://confluence.atlassian.com/jirakb/how-to-find-any-custom-field-s-ids-744522503.html

The value is an array of 1 value.

 

Regards

 

Magnus
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!
September 25, 2024

Thanks for the excellent answer.

I was able to retrieved what I needed with (My test bash snippet):

resp=$(curl -s -H "Accept: application/json" -H "Authorization: Bearer ${token}" https://${url}/rest/api/2/issue/XXXX_XX-41825)
testplan=$(echo "${resp}" | jq -r '.fields.customfield_18045[0]')
echo "testplan=$testplan"

 /Magnus

TAGS
AUG Leaders

Atlassian Community Events