Is there a workaround to https://jira.atlassian.com/browse/JRA-24118 ? BTW Please vote!
I need to add a label to some issues based on issue navigator search result. Bulk edit erases old labels and adds new which does not work for me.
Is there coding-free option?
Get Script Runner plugin and execute following Groovy script:
import com.atlassian.jira.web.bean.PagerFilter import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.label.LabelManager import com.atlassian.jira.bc.JiraServiceContextImpl filterId = 10000 labelName = 'Label' cm = ComponentManager.instance labelManager = ComponentManager.getComponentInstanceOfType(LabelManager.class) searchRequestService = cm.searchRequestService searchProvider = cm.searchProvider user = cm.jiraAuthenticationContext.getLoggedInUser() ctx = new JiraServiceContextImpl(user) sr = searchRequestService.getFilter(ctx, filterId) searchResult = searchProvider.search(sr?.getQuery(), user, PagerFilter.unlimitedFilter) searchResult.issues.each{issue -> labelManager.addLabel(user, issue.id, labelName, false) } "Done."
Adapt filterId and labelName to your needs.
Henning
Is this going to send any email notifcations or not? I will it will not send them.
It depends on the last parameter for addLabel(). If it's false like here, no notifications are send. If it's true, notifications are send.
Thank you. Due to the nature of the problem we decided to implement a SMTP filter for changes made by a service account jira user.
@Henning Thanks for your example. I used it and modified to create a script to remove a single label.
Wanted to post it in case anyone else is looking to bulk rename labels. I'd suggest add new label then remove old.
import com.atlassian.jira.web.bean.PagerFilter import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.label.LabelManager import com.atlassian.jira.bc.JiraServiceContextImpl filterId = 10602 labelName = 'Label' cm = ComponentManager.instance labelManager = ComponentManager.getComponentInstanceOfType(LabelManager.class) searchRequestService = cm.searchRequestService searchProvider = cm.searchProvider user = cm.jiraAuthenticationContext.getLoggedInUser() ctx = new JiraServiceContextImpl(user) sr = searchRequestService.getFilter(ctx, filterId) searchResult = searchProvider.search(sr?.getQuery(), user, PagerFilter.unlimitedFilter) searchResult.issues.each{issue -> labelManager.setLabels(user, issue.id, (labelManager.getLabels(issue.id).collect{l -> l.getLabel()}.minus(labelName)) as Set, false, true) } "Label" + labelName + " removed from issues in filter " + filterId.toString()
It looks like you're new here. Sign in or register to get started.