Hello Community,
Using Scriptrunner I am searching JQL to identify an array of issues identified as "keyResult". Those issues are being (each) evaluated for a couple of things - StatusCategory is "Done" and the issues linked to it by a particular link type. Crux of the code:
//return JQL;
def keyResult = issuekey['issues']['key']
//return the results of a JQL search as 'keyResult'
if (keyResult) {
for(each in KeyResult){
def getIssue = get('/rest/api/2/issue/' + each)
.asObject(Map)
.body
def linkedIssueStatusCategories = getIssue['fields']['issuelinks']['inwardIssue']['fields']["status"]['statusCategory']['name']
return linkedIssueStatusCategories;
//Look for issues with specific link type "is resolved by"
def resolutionStatus = getIssue['fields']['issuelinks']['type']['inward']
def resolutionStatusList = resolutionStatus.findAll { item -> item.contains('is resolved by') }
//Check that the tickets linked via "is resolved by" are 'Done'
def areAllChildrenDoneTest = (linkedIssueStatusCategories.every{obj -> obj == "Done"} && resolutionStatusList != [] && resolutionStatusList)
if (AllChildrenDone == true) {
There's a block of actions following if the statement is true. The problem is the "linkedIssueStatusCategories.every" statement. For this to work, there's going to be cases where not all linked issues are "Done". The only issues I care to evaluate, are those under a specific linked issue relationship "is resolved by". If an issue is linked by another type, I'm happy to disregard. However for this to be true, all issues with that link type need to be considered "Done".
Example issue api returns
{ "id": "111", "self": "https://xxx.atlassian.net/rest/api/2/issueLink/111", "type": { "id": "111", "name": "Resolvers", "inward": "is resolved by", "outward": "resolves", "self": "https://xxx.atlassian.net/rest/api/2/issueLinkType/111" }, "inwardIssue": { "id": "111", "key": "yyy-zzz", "self": "https://xxx.atlassian.net/rest/api/2/issue/111", "fields": { "summary": "some summary goes here", "status": { "self": "https://xxx.atlassian.net/rest/api/2/status/111", "description": "", "iconUrl": "https://xxx.atlassian.net/images/icons/statuses/generic.png", "name": "Shipped", "id": "111", "statusCategory": { "self": "https://xxx.atlassian.net/rest/api/2/statuscategory/3", "id": 3, "key": "done", "colorName": "green", "name": "Done" } },
The issue link relationship (fields.type.inward) is separated from the properties of the issue (fields.inwardIssue.fields.status.statusCategory).
Could someone help me to evaluate a statement that considers the specific link relationship type, and the statusCategory for that particular issue? I'm looking to find, only and all issues that are linked in a particular way, and where those issues are "Done".