Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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 jira-install/lib then you will need to use JEMH 4.1.33+ and then use the following instead of lines 7 and 8:

  • Code Block
    var filter = pagerFilter;
    var builder = jqlQueryBuilder;

These specific classes were not initially added, are available since JEMH 4.1.33+

Code Block
breakoutModewide
var emailSubject = jemhUtils.hash(subject); //Gathers the email subject
var foundIssue = "";

    //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 to search for issues with the Summary that is the same as the email subject
    var fullQuery = builder.where().field("Summary_hash").like(emailSubject).buildQuery();
    
    //get list of issues (could be empty)
    var fullResults = searchService.search(user, fullQuery, filter).getResults();

    if (relatedIssue !== null) //Checks whether the related issue is found within the list of these results. If so a comment will be added
    {
        if (fullResults.size() > "0") //Checks if the query returned any values, if so then it checks if the related issue is found in query
        {
            
            for(i =0; i < fullResults.size(); i++) //Checks if related issue is found in query results, if not then new issue will create
            {
                if(relatedIssue.getKey() == fullResults[i].getKey())
                {
                                        foundIssue= relatedIssue.getKey();
                }
                else //related issue not found in query result so a comment will be added to the first found issue in the query result
                {
                    if (fullResults.size()>0) //related issue not found in query, will create new issue
                    {
                        var issue = fullResults[0];
                        var foundIssue = issue.getKey();
                    } 
                }
            }
        }
        else //related issue not found in query, will create a new issue using following params
        {
            print("no results from JQL query");
            resultMap.put("issueKey", "");
            resultMap.put("project", "Service Project"); //sets the project that the issue should be created within
            resultMap.put("issueType", "task"); //sets issuetype that the issue should be
            
        }
    }
    else //if there is no related issue then it JEMH will comment on the first value found in the JQL query results
    {
        if (fullResults.size()>0) 
        {
            var issue = fullResults[0];
            var foundIssue = issue.getKey();
            print("Found issue using JQL "+fullQuery+" : "+foundIssue);
        } else {
            print("No issues match using JQL: "+fullQuery + " running partial Query");
        }
    }
    
    
    if(foundIssue !== "") //Sets the Issue that it should comment on based on the query result.
    {
        print("commenting on: " + foundIssue);
        resultMap.put("issueKey", foundIssue);
    }
    else
    {
        print("no issue found, creating a new issue");
        resultMap.put("Summary_hash", emailSubject);
    }