this days i tested about jira upgrade from ver 4.4.5(standalon, redhat) to 5.0.5(war, open suse, vm enviroment)
there is a groovy script issue.
this script is work well at jira version 4.4.5. but make a issue at jira version 5.0.5
//===========================================================
import com.atlassian.jira.user.util.UserUtilImpl
//import com.atlassian.core.user.GroupUtils
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.groups.DefaultGroupManager
import com.atlassian.jira.issue.comments.CommentManager
import com.opensymphony.workflow.WorkflowContext
//log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
//log.debug ("test " + "test")
//log.error "error"
def allowGroupStr = "crowd-project"
def addUsers = "User to grant"
def addGroups = "Group to add"
String commentValue = ""
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
CustomField customFieldaddUsers = customFieldManager.getCustomFieldObjectByName( addUsers )
println "***" + customFieldaddUsers +"***"
addUsersFieldVal = issue.getCustomFieldValue( customFieldaddUsers )
println "***" + addUsersFieldVal + "***"
CustomField customFieldaddGroups = customFieldManager.getCustomFieldObjectByName( addGroups )
addGroupsFieldVal = issue.getCustomFieldValue( customFieldaddGroups )
//IssueFactory issueFactory = componentManager.getIssueFactory()
//MutableIssue issue = issueFactory.getIssue()
//User currentUser = componentManager.getJiraAuthenticationContext().getUser()
String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();
println "*** test code ****"
User userToAdd1 = UserUtils.getUser( "test11" )
println "***test" + userToAdd1 +" **test**"
===========================================================//
from this script
fail to getCustomFieldValue and getUser.
the error log is
//============================================================
***User to grant***
***[com.atlassian.crowd.embedded.ofbiz.OfBizUser@ab3680ae]***
*** test code ****
***testcom.atlassian.crowd.embedded.ofbiz.OfBizUser@ab3680ae **test**
=============================================================//
I don't know why this error message is printed.
do you know the solution?
plz help me :)
Hi Jiyoung,
I have made some changes in your code to make it run on Jira 5
import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.crowd.embedded.api.User; import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.security.groups.GroupManager; import com.atlassian.jira.issue.comments.CommentManager import com.opensymphony.workflow.WorkflowContext import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.comments.CommentManager import com.opensymphony.workflow.WorkflowContext import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.issue.Issue; //log = Category.getInstance("com.onresolve.jira.groovy.PostFunction") //log.debug ("test " + "test") //log.error "error" def allowGroupStr = "crowd-project" def addUsers = "User to grant" def addGroups = "Group to add" String commentValue = "" // get all managers if possible using ComponentAccessor CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager() // please use this in Jira 5 GroupManager groupManager = ComponentAccessor.getGroupManager() CustomField customFieldaddUsers = customFieldManager.getCustomFieldObjectByName( addUsers ) println "***" + customFieldaddUsers +"***" List addUsersFieldVal = issue.getCustomFieldValue( customFieldaddUsers ) addUsersFieldVal.each() {println "*** " + it.getName()} println "***" + addUsersFieldVal + "***" CustomField customFieldaddGroups = customFieldManager.getCustomFieldObjectByName( addGroups ) addGroupsFieldVal = issue.getCustomFieldValue( customFieldaddGroups ) //IssueFactory issueFactory = componentManager.getIssueFactory() //MutableIssue issue = issueFactory.getIssue() //User currentUser = componentManager.getJiraAuthenticationContext().getUser() User currentUserObject = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller(); println "*** test code ****" User userToAdd1 = ComponentAccessor.getUserUtil().getUserObject("test11" ) // use getName(). toString() is not implemented anymore for crowd user objects println "***test" + userToAdd1.getName() +" **test**" println "***current user" + currentUserObject.getName() +" **current user**"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are some API changes in 5.0 onwards . Have a look at this .
You will have to update your script accordingly to the updated API
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.