Hi Guys,
I'm try to write some groovy script what should re-assign issue based on current assignee, but it wont work not even start. JIRA what I use is 6.3.15 and SR version is 3.1.3. I'm running script as a post function
Code of my Script. Thanks in advice for Help
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.MutableIssue MutableIssue issue = issue; def userManager = ComponentAccessor.getUserManager() def Admin1 = userManager.getUserByName('Admin1')?.directoryUser def User1 = userManager.getUserByName('User1')?.directoryUser def Tester1 = userManager.getUserByName('Tester1')?.directoryUser def Admin2 = userManager.getUserByName('Admin2')?.directoryUser def User2 = userManager.getUserByName('User2')?.directoryUser def Tester2 = userManager.getUserByName('Tester2')?.directoryUser //Team 1 if(issue.assignee.equals(Admin1)) { issue.setAssignee(Tester1)} if(issue.assignee.equals(User1)) { issue.setAssignee(Tester1))} if(issue.assignee.equals(User1)) { issue.setAssignee(Tester1))} //Team 2 if(issue.assignee.equals(Admin2)) { issue.setAssignee(Tester2)} if(issue.assignee.equals(User2)) { issue.setAssignee(Tester2))} if(issue.assignee.equals(User2)) { issue.setAssignee(Tester2))}
Your script should look like the following. Note i've used == in the if statement and camel-cased variable names so its more readable.
This should set the assignee for you on the transition.
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.MutableIssue MutableIssue issue = issue; def userManager = ComponentAccessor.getUserManager() def admin1 = userManager.getUserByName('Admin1')?.directoryUser def user1 = userManager.getUserByName('User1')?.directoryUser def tester1 = userManager.getUserByName('Tester1')?.directoryUser def admin2 = userManager.getUserByName('Admin2')?.directoryUser def user2 = userManager.getUserByName('User2')?.directoryUser def tester2 = userManager.getUserByName('Tester2')?.directoryUser //Team 1 if (issue.assignee == admin1) { issue.setAssignee(tester1) } if (issue.assignee == user1) { issue.setAssignee(tester1) } if (issue.assignee == user1) { issue.setAssignee(tester1) } //Team 2 if (issue.assignee == admin2) { issue.setAssignee(tester2) } if (issue.assignee == user2) { issue.setAssignee(tester2) } if (issue.assignee == user2) { issue.setAssignee(tester2) }
Sitll error . I have it first as post function and in place of "Admin1" my username form JIRA right ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you see any error messages? Anything in the logs to indicate what the problem is?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
2016-05-12 13:28:20,017 http-bio-8443-exec-7 ERROR mbeczynski 808x33394x1 1nspkgu 195.205.243.130 /secure/WorkflowUIDispatcher.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] *************************************************************************************
2016-05-12 13:28:20,018 http-bio-8443-exec-7 ERROR mbeczynski 808x33394x1 1nspkgu 195.205.243.130 /secure/WorkflowUIDispatcher.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: SGSP-53, actionId: 711, file: /var/atlassian/application-data/jira-production/scripts/InProgressToCodeReview.groovy
Only This nothing what could help me
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you try removing all of your script and just having the following line in it and seeing if that runs correctly? If that works then its likely to be an error in the script.
log.warn("Running script")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nothing at console, so it can be something wrong with JIRA or Script Runner plugin ??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you still see same error message in the logs?
016-05-12 13:28:20,017 http-bio-8443-exec-7 ERROR mbeczynski 808x33394x1 1nspkgu 195.205.243.130 /secure/WorkflowUIDispatcher.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] *************************************************************************************
2016-05-12 13:28:20,018 http-bio-8443-exec-7 ERROR mbeczynski 808x33394x1 1nspkgu 195.205.243.130 /secure/WorkflowUIDispatcher.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: SGSP-53, actionId: 711, file: /var/atlassian/application-data/jira-production/scripts/InProgressToCodeReview.groovy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
nope it just show nothing at all, I made perform reindexing now maybe that will resolve this issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It seems like the post-function isn't firing. Do you have permission to do the transition?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yep I had all permission it start work after re index instance + clear cache and groovy internal cache and re index issue at project . Thanks you for your time and help if you will be at Poland let me know I own you a beer
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.
Your script won't compile. You have extra ')' near the if statements. Are you adding this script as part of a post-function or listener? More details would be good so I can give you a more useful answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.