...
Info | ||
---|---|---|
Due to issues highlighted on the following page,https://thepluginpeople.atlassian.net/wiki/spaces/JEMH/pages/3974856709/Using+Java+17#Classnotfound-exception-when-using-%E2%80%9Cjava.type%E2%80%9D. It means that if you are using Java 17 with Nashorn installed within
These specific classes were not initially added, but are available since JEMH 4.1.33 |
Script
Code Block |
---|
//create regexp pattern to extract external id // var pattern = Java.type("java.util.regex.Pattern").compile("External ID: (([0-9]{10}) (Blue|Green|Orange|Teal))"); //This Pattern has 2 capture Groups: /* # Full Match: 1234567890 Blue # Partial Match: 1234567890 # Colour Match Blue (ignored) */ //Create a patternMatcher for the subject var matcher = pattern.matcher(subject); //define empty values for the full, and partial match var foundExternalFull = ""; var foundExternalPartial = ""; //if match exists set the found external values if (matcher.find()) { var groupOne = matcher.group(1); if (groupOne) { foundExternalFull = groupOne; } var groupTwo = matcher.group(2); if (groupTwo) { foundExternalPartial = groupTwo; } } //define values for the related issue keys for commenting and creating a subtask var issueWithExternalId = ""; var parentIssueWithExternalId = ""; //If a regexp match is found, check existing issues for the same value if(foundExternalFull){ print("Found a TicketID of [" + foundExternalFull + "]"); //get the user to run the JQL query as var user = userManager.getUserByName("admin"); var filter = Java.type("com.atlassian.jira.web.bean.PagerFilter").getUnlimitedFilter(); var builder = Java.type("com.atlassian.jira.jql.builder.JqlQueryBuilder").newBuilder(); //construct the JQL query for a Full match var fullQuery = builder.where().field("Ticket Key").like(foundExternalFull).buildQuery(); //get list of issues (could be empty) var fullResults = searchService.search(user, fullQuery, filter).getResults(); //get first issue if exists and add via issueKey directive to comment if (fullResults.size()>0) { var issue = fullResults[0]; issueWithExternalId = issue.getKey(); print("Found issue using JQL "+fullQuery+" : "+issueWithExternalId + " " + foundExternalFull); } else { print("No issues match using JQL: "+fullQuery + " running partial Query"); builder.clear(); //construct a JQL Query for a partial match (for Parent Issue Key) var partQuery = builder.where().field("Ticket Key").like(foundExternalPartial).buildQuery(); //get list of issues (could be empty) var partResults = searchService.search(user, partQuery, filter).getResults(); if (partResults.size()>0) { // cycle through each partial match for(var i = 0; i < partResults.size(); i ++){ var issue = partResults[i] //if the issue is not already a subtask, then it is the parent issue if(!issue.getIssueType().isSubTask()){ parentIssueWithExternalId = issue.getKey(); print("Found Parent Issue match using JQL "+partQuery+" : "+issueWithExternalId); break; } } } } //Setup issue values //if an issue for commenting is found, set the current issue key to this value if (!issueWithExternalId.isEmpty()) { resultMap.put("issueKey",issueWithExternalId) //else if not commenting, set the Ticket Key value to the extracted ID for future use } else if (!foundExternalFull.isEmpty()) { resultMap.put("Ticket Key",foundExternalFull); } //if a parent issue key is found, setup the issue as a Sub-Task if (!parentIssueWithExternalId.isEmpty()) { resultMap.put("parentIssueKey",parentIssueWithExternalId); resultMap.put("issueType", "sub-task") resultMap.put("priority", "low"); } } |
...