Is there any way to add bulk groups to multiple events in Notification Scheme?

Hi,

Do we have any script/workaround to add multiple groups to the different events in Notification Scheme, looking for to avoid the manual task.

Regards,

Arpita Argulwar

1 answer

Here's a sample script:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.type.EventType;
import com.atlassian.jira.event.type.EventTypeManager;
import com.atlassian.jira.notification.NotificationSchemeManager;
import com.atlassian.jira.notification.NotificationTypeManager;
import com.atlassian.jira.notification.NotificationType;
import com.atlassian.jira.scheme.SchemeEntity;
import com.atlassian.jira.scheme.SchemeManager;

def manager = ComponentAccessor.getNotificationSchemeManager();
def typeManager = ComponentAccessor.getComponent(NotificationTypeManager.class);
def eventTypeManager = ComponentAccessor.getComponent(EventTypeManager.class);

//
def schemeName = "OPS Notification Scheme"
def scheme = manager.getScheme(schemeName)
def type = "Group_Dropdown"
def groups = ["administrators", "users"]
def eventTypeIds = [EventType.ISSUE_CREATED_ID, EventType.ISSUE_UPDATED_ID]

//For each event add each group
eventTypeIds.each() {eventTypeId -> 
    groups.each() {groupName ->
        //Add entry for each group
    	def rawValue = typeManager.getNotificationType(type).getArgumentValue(groupName);    
        SchemeEntity schemeEntity = new SchemeEntity(type, rawValue, eventTypeId, null);
        if (!manager.hasEntities(scheme, eventTypeId, type, rawValue, null))
        {
            manager.createSchemeEntity(scheme, schemeEntity);
        }
    }    
};

Thanks Boris..Let me check.

You should have said that you're running JIRA 3.x. This script is for JIRA 6.

I'm not able to provide JIRA 3 compatible script.

Hello Boris,

I have tried the above code and received the following error:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Script1.groovy: 1: unable to resolve class com.atlassian.jira.component.ComponentAccessor

My guess from the above error is, ComponentAccessor is not compatible with Jira 3.13 version.

Please suggest further.

Regards,

Arpita


Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,316 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot