Is there a way to automatically add a label to an issue when it goes to a specific status?

Isaac Myman
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 10, 2019

I want to have a label added automatically when an issue goes to a status of ready for development. I want to do this because my idea is to set up 2 separate boards for the project 1 for the PMs, leads, etc. and one specifically for the developers. The one for the developers would only show issues that have this label and therefore would only show issues that are actively being developed or are ready for development. Rather than needing to assign the issue to a developer, change the status, and add the label so it shows on the board I would like to automate as much of that process as I can getting it down to 2 actions or even one if I can. 

1 answer

2 votes
Petter Gonçalves
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 10, 2019

Hello Isaac,

Welcome to Atlassian community!

Unfortunately, JIRA does not have any post functions to add labels once the issue is transitioned. We have a feature request to implement this functionality here:

Ability to add and remove labels in Post Function to Workflow Transition

Feel free to vote and watch the suggestion to increase its priority and also receive notifications about any updates.

For now, there are some plugins you can use to get it implemented on JIRA Cloud or Server. Here are the most common options:

1 - Use Automation for JIRA and configure the following rule:

Screen Shot 2019-04-10 at 19.17.27.png

2 - Use Scriptrunner plugin and configure the following Script, as mentioned on this thread:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.bc.issue.label.LabelService
import com.atlassian.jira.bc.issue.label.LabelService.AddLabelValidationResult
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.security.JiraAuthenticationContext
import com.opensymphony.user.User
import org.apache.log4j.Category

ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
JiraAuthenticationContext authenticationContext = componentManager.getJiraAuthenticationContext()
User user = authenticationContext.getUser()
LabelService labelService = ComponentManager.getComponentInstanceOfType(LabelService.class)

MutableIssue myIssue = issue

["somelabel", "someotherlabel"].each {String labelName ->
    AddLabelValidationResult validationResult = labelService.validateAddLabel(user, myIssue.id, labelName)
    if (!validationResult.errorCollection.hasAnyErrors()) {
        labelService.addLabel(user, validationResult, false)
    }
}

Let us know if this information helps.

Suggest an answer

Log in or Sign up to answer