Oliver T.
Oliver T.

Reputation: 11

Jira Xray GraphQL: latest results at first

I'm trying to implement an Automation Rule for Xray Test Executions in Jira Cloud.

To do this, I send a GraphQL request at one point, where I get a lot of test executions.

POST
Custom Data
{"query": "{getTestExecutions(jql: \"project = ‘ABC’ and status = 'XYZ'\", limit: 100) {results {issueId}}}"}

Then I continue working with the IDs obtained in this way.

My problem is that the jql query returns more than 100 results. Unfortunately, the oldest results are always returned first. However, I am interested in the latest results. This means that usually only for test executions that have been created/modified within the last seven days. How can I get the latest IDs? I've thought of one of these possibilities, but I don't know if/how to implement it:

  1. Sorting of the results of my query by the date of creation. (Unfortunately, adding 'order by created DESC' to the jql query had no effect.)
  2. A restriction of the result set to the most recently created/modified test executions. (There is probably the possibility to use the parameter 'modifiedSince', but I couldn't figure out if/how you can restrict e.g. only the test executions created/changed within the last week.) Do you have any idea how I can solve the problem?

Thank you in advance. Oliver

Upvotes: 0

Views: 30

Answers (1)

Sérgio
Sérgio

Reputation: 2129

You can address this need in 2 ways:

a) using the modifiedSince argument on the GraphQL call, as you mentioned. This date should be in the format: YYYY-MM-DDTHH:mm:ssZ. So you need to build that reference date in some step before on Jira automation.

As a side note, this will correspond to making a GraphQL call like

   query
    {
        getTestExecutions(jql: "project = CALC", limit: 10, modifiedSince: "2025-01-10T00:00:00Z") {
            results{
            issueId
            jira(fields: ["key"])

        }
    }
 }

b) or on the JQL, using a query to consider the "updated" date; note that this won't take into account changes made on the related Test Runs, just on the Test Executions issues themselves.. so a) above is more clean.

project = CALC and issuetype = "Test Execution" and updated > -30days

Upvotes: 0

Related Questions