Page tree

This documentation relates to an older version 5.2 of the Structure for Jira. Visit the current documentation home.

Skip to end of metadata
Go to start of metadata

This script will set the labels fields to a certain value for all the issues that satisfy a defined JQL query.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.label.LabelManager

// list of elements to consider for matching

def searchlist = ["foo", "bar", "bar"]

def labelName = 'Partner'

def labelManager = ComponentAccessor.getComponent(LabelManager)
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
def searchService = ComponentAccessor.getComponent(SearchService)

for (searchItem in searchlist){
    def jqlSearch = "company = $searchItem"
    def parseResult = searchService.parseQuery(user, jqlSearch)
    if (parseResult.isValid()) {
        def searchResult =, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
        searchResult.issues.each{issue -> labelManager.addLabel(user,, labelName, false)
  • No labels