Your issue stems from incorrect Xray workflow post-function configuration and execution order. Here’s the comprehensive solution:
Xray workflow post-function configuration:
Remove your custom post-function with XrayTestExecution.updateStatus() - this is not a valid Xray API method. Instead, use Xray’s built-in post-function. In your workflow editor, select the ‘Resolve’ transition, click ‘Post Functions’, and add ‘Update Linked Test Execution Status’ (provided by Xray). Configure it to set the test execution status to ‘TODO’ rather than ‘PASS’ - this flags the test for re-execution by your QA team, which is more appropriate than automatically marking it as passed just because the defect is resolved.
If you don’t see Xray post-functions in the list, verify Xray is properly installed and enabled: Admin > Manage Apps > Xray for Jira > ensure it’s enabled and has workflow post-function modules active.
Order of post-functions affecting status updates:
This is critical for reliable execution. Your post-function order should be:
- Set issue status to the linked status (default)
- Update change history (default)
- Fire event that can be processed by listeners (default)
- Update Linked Test Execution Status (Xray) ← Add here
- Re-index issue (default)
The Xray function must run AFTER ‘Fire event’ so the defect status change is fully committed to the database, but BEFORE ‘Re-index issue’ so the test execution status update is included in the index refresh. If Xray runs too early, it reads the old defect status; too late, and the test execution update doesn’t propagate to search/dashboards.
Bulk recalculation of test execution status:
For the 40% of test executions that didn’t update (likely from earlier defect resolutions before you fixed the post-function), you need to bulk recalculate. Use Xray’s REST API to trigger bulk updates:
Navigate to Admin > System > Advanced > REST API Browser, or use curl:
POST /rest/raven/1.0/api/testexec/{testExecKey}/status
{"status": "TODO"}
Alternatively, create a JQL filter for failed test executions linked to resolved defects: type = "Test Execution" AND status = FAIL AND issueFunction in linkedIssuesOf("status = Resolved", "is tested by"), then use Xray’s bulk operations to set status to ‘TODO’.
Defect-test traceability in DC environments:
In Jira DC, ensure your Xray license covers all nodes and that the Xray index is synchronized across the cluster. Check Admin > System > Xray Settings > Index Status. If the index is out of sync, test execution updates may not propagate correctly across nodes. Run ‘Rebuild Xray Index’ if you see inconsistencies.
For dashboard accuracy, configure your QA dashboard gadgets to use Xray’s native test execution filters rather than generic Jira filters. This ensures real-time status updates are reflected correctly without index lag.