Hi,
I'm on Jira Cloud and I want to autofill a custom field on a Test execution: when a Test Execution is created on a Test page, set custom field value on Test execution inherit from with the value of the custom field on Test.
On Jira Data Center, I used Scriptrunner and the custom field “Tests association with a Test Execution” to get the issue key of the Test, and then get the value of the custom field.
In cloud version, the “Test association with a Test Execution” custom field does not exist anymore.
I read about Xray REST API and GraphQL but I don't know how to use it with scriptrunner (authenticattion, call, and so on)
I tried also with Jira Cloud Automation but I don't know what conditions to choose to link Test Execution and Test.
Do you know how can I autofill a custom field of a Xray Test Execution from the Test custom field value on Jira Cloud ?
Thank you.
Hi,
I found a solution using Xray GraphQL API.
As GraphQL have a specific format, I used an online tool to convert the GraphQL query (found on Xray documentation) to convert it to a JSON body for the POST request.
import groovy.json.*
// get Xray API token using Xray REST API
def idclient = JsonOutput.toJson([client_id: "my_xray_api_id", client_secret: "my_xray_api_secret"])
def getToken = post('https://xray.cloud.getxray.app/api/v2/authenticate').header('Content-Type', 'application/json').body(idclient).asObject(Map)
def apiToken = getToken.headers['x-access-token'][0]
// get Test Execution key
def issueKey = issue.key
// GraphQL query in JSON body format
def msg = [ "query":"{ getTestExecutions(jql: \"key = ${issueKey}\", limit: 10) { results { tests(limit: 10) { results { jira(fields: [\"key\"]) } } } }}" ]
// call GraphQL API function
def result = post('https://xray.cloud.getxray.app/api/v2/graphql')
.header('Content-Type', 'application/json')
.header('Authorization', "Bearer ${apiToken}")
.body(msg)
.asObject(Map)
if(result.status == 200){
// rest of my code
}
Hi @thibaud.norguet-sc !
Could you help me to add this API and use it?
I've been reading about this, and can't figure they way to add it and apply it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @thibaud.norguet-sc - welcome to the community,
As I mainly try to solve things with A4J in cloud and the only experience I have with scriptrunner is on Server/DC I´m wondering how this could be done here.
The action itself (test is added to test execution) is an xray specific action --> means jira native, therefore A4J could not grab this event with a trigger.
How did you grab the event on Server in your scriptrunner solution?
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your reply
The main purpose is to facilitate Test Execution creation for end user.
So the trigger is not when a test is added to a Test Execution, but when a Test execution is created from an existing Test, so Test Execution inherit values from the Test and user don't have to fill the field manually.
On Server/DC, I created a post function on Test Execution workflow : when a Test Execution is created, the scriptrunner script is run to get and set the values.
I finally found a solution for my issue using Xray GraphQL API (this is the only way to get Xray datas in Cloud, a lot of Xray custom fields disappeared from Server/CD to Cloud).
Best.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
good to know you found a solution.
Would you be so kind to post you solution here to share with other users that might be faced with similar problems?
You could post it as an answer to your own question and then mark it as accepted with the accept button. This will mark the question as solved and help other users finding appropriate solutions.
Best
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @thibaud.norguet-sc
Is there any way that can get the over all execution status of the test execution like passed or Failed or ToDo and update in a custom field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.