I use this script to add users for the selected component, everything works, but now I need to add a group and not a user, what do I need to change to make everything work?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.ApplicationUser
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def cf = ComponentAccessor.customFieldManager.getCustomFieldObject(10032L); //Соисполнители
def arrayOfComponents = issue.getComponents();
def userList = getCustomFieldValue(issue,10032L)?:[];
for(def comp in arrayOfComponents){
if(comp.getName()=="Email (Почта)"){
userList += [getUser("r.sheraliev")];
}
if(comp.getName()=="FTP (Uzmobile)"){
userList += [getUser("a.malikov")];
}
if(comp.getName()=="AD (Домен)"){
userList += [getUser("o.gulomkodirov")];
}
if(comp.getName()=="JIRA (Confluence)"){
userList += [getUser("m.zaxidov")];
}
if(comp.getName()=="Local Administartor"){
userList += [getUser("o.shodmonov")];
}
if(comp.getName()=="Oasis"){
userList += [getUser("a.malikov")];
}
}
issue.setCustomFieldValue(cf, userList.collect{it})
ComponentAccessor.getIssueManager().updateIssue(currentUser, issue, EventDispatchOption.ISSUE_UPDATED, false)
ApplicationUser getUser(String userName){
return ComponentAccessor.getUserManager().getUserByName(userName)
}
def getCustomFieldValue(issue, Long fieldId) {
issue.getCustomFieldValue(ComponentAccessor.customFieldManager.getCustomFieldObject(fieldId))
}
What are you trying to add the group to? The code you've given us only shows what you're doing with users.
I have components that are written in the script, the components are being added to the users in the field! and it is necessary for me that instead of users groups with users instead of users were added. I apologize for singing English.
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.