Some customers and some partners may be using ScriptRunner in order to automate some tasks and even extend the features provided by Jira.
You can also do some automation related with Xray, specially because we use Jira entities and concepts.
ScriptRunner may be used in order to access existing features or even to extend the built-in features.
Let us know if you're using also ScriptRunner and your use cases so we can improve and share them with other users.
Please note
The following scripts are provided as-is, no warranties attached. Use these scripts carefully.
Please feel free to adapt them to your needs.
Note: We don't provide support for ScriptRunner; if you have doubts concerning its usage, please contact ScriptRunner's support.
Examples
Validate coverable issues upon making a transition
Sometimes you may need to assure that the coverable issue (e.g. requirement) is covered before transitioning it to some status, or before resolving it.
The following script validates the requirement based on the directly linked tests to it.
Please note
This solution is not perfect for several reasons, so please take the following notes into consideration:
- this should be implemented as a workflow condition (currently it's not possible with ScriptRunner on Jira Cloud)
- the tests association should be validated properly, based on all the direct linked tests and on the ones linked to "sub-requirements"
You need to:
- edit the workflow transition of the "coverable issue" (e.g. story, requirement), by editing the related workflow
- add a ScriptRunner Post Function, in the Post Functions tab
Reopen/transition linked Tests to a covered issue
Whenever you change the specification of a requirement, for example, you most probably will need to review the Tests that you have already specified.
The following script tries to make a transition on all linked Tests to a requirement. You can hook it to a post-function on the transition of the covered issue.
Please note
This solution is not perfect because the tests association should be validated properly, based on all the direcly and indirectly linked tests.
You need to:
- edit the workflow transition of the "coverable issue" (e.g. story, requirement), by editing the related workflow
- add a ScriptRunner Post Function, in the Post Functions tab
Show Tests Count for a requirement
In the following example, we'll create a text custom field to show the total amount of directly linked Tests to a given coverable issue.
Please note
ScriptRunner for Jira Cloud does not provide scripted field; thus, we have to create a standard text (single line) custom field and we'll update it periodically. For the later, we'll use a periodic job.
You need to:
- create a text (single line) custom field (e.g. "Tests Count")
- create a ScriptRunner scheduled job