Hi there,
I've built this script to send a Google form on every closed JIRA depending on a user group.
However, since we upgraded our JIRA instance to 7.12.1, it's stopped working with the following error:
[Static type checking] - Cannot assign value of type com.atlassian.jira.component.pico.ComponentManager to variable of type com.atlassian.jira.ComponentManager @ line 16, column 37.
Our code is hosted on a linux server: /EFS_Disk/data/jira/sharedhome/groovyscripts/IC/pf-feedback-email.groovy
import com.atlassian.crowd.embedded.api.Group
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.groups.GroupManager
import com.atlassian.mail.MailException
import com.atlassian.mail.queue.MailQueueItem
import com.atlassian.mail.queue.SingleMailQueueItem
import com.atlassian.jira.mail.Email
import com.atlassian.jira.config.properties.ApplicationProperties
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.config.properties.APKeys
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.opensymphony.workflow.WorkflowException
ComponentManager componentManager = ComponentManager.getInstance()
GroupManager groupManager = ComponentAccessor.getGroupManager();
ApplicationProperties applicationProperties = ComponentAccessor.getApplicationProperties()
String baseUrl = applicationProperties.getString(APKeys.JIRA_BASEURL)
Issue issue = issue;
ApplicationUser reporter = issue.getReporterUser()
Group itgroup = groupManager.getGroup("IT Services")
if (!groupManager.getUserNamesInGroup(itgroup).contains(reporter.getName()))
{
Email email = new Email(reporter.emailAddress);
email.setSubject("JIRA " + issue.key+" has been closed, How did it go?");
email.setFrom("jira@just-eat.com");
email.setMimeType("text/html");
StringBuilder sb = new StringBuilder();
sb.append("<b>Hi "+reporter.getDisplayName().split(" ")[0]+",</b><br><br>");
sb.append("Please help us get better by telling us what you think about our service and how we dealt with your JIRA.<br><br>")
sb.append("<a href=\"https://docs.google.com/forms/d/e/1FAIpQLSdCFyQPM3EE60vujBojf5ebGzLQNXkHaEIrGXYCnIJ_uAO7mw/viewform\">")
sb.append("It will only take a minute...");
sb.append("</a> <---- Click here for survey<br><br>");
sb.append("We'd really appreciate it as the feedback will feed into our performance and development plans.<br><br>Thank you from<br><b>End-User Computing</b>");
email.setBody(sb.toString());
MailQueueItem singleMailQueueItem = new SingleMailQueueItem(email);
try
{
singleMailQueueItem.send();
}
catch (MailException e)
{
throw new WorkflowException("Failed to send Feedback Email due to: " + e.getMessage(), e);
}
}
Please let me know how I can resolve this.
Thanks,
Anthony
Did you try to remove this line?
ComponentManager componentManager = ComponentManager.getInstance()
I don't see you using componentManager anywehere in your code.
Even if you did, don't use ComponentManager, it's an old library replaced by ComponentAccessor which i see you do use.
Please try and let me know.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.