It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Is there a way to automatically add a Label for a created JIRA issue?

I've setup a Zapier integration so that any new alerts in PagerDuty will create a new issue in JIRA for our Ops team to see.

Is there any way to automatically add a Label to these newly created JIRA issues? So the workflow might look like:

PagerDuty alert > new JIRA issue created > the "PD-Alert" Label is automatically added to the JIRA issue

Is this possible at all?

8 answers

Solved this without expensive plugins for Jira enterprise V7.4.2:

1 Edit the workflow->"create transition" to add a post function to the create step. 

2 (for some reason you cant edit label as a field directly) so add your label-name to a tmp custom field that is a text string.

3 add another post function that copied this field to the labels field

4 clear the tmp custom field value.

This is an excellent answer! Though, can you think of a way to filter this on an issue created by email? Meaning, if you only want to auto-label issues created by email... 

Like Christian Gaitan likes this

*This is a fix for Jira Service Desk*

I was able to solve this with a simple non workflow related workaround

Project Settings -> Request types- >Edit the request you want to add labels to -> Add  a "Hidden" labels field with the label you need in "Preset value". This will ensure that when the issue is created, the label automatically gets added to a issue of that type.

Use Jira Automation plugin, the Lite (free) version should work.

  1. Trigger: Issue Created
  2. Condition: Your JQL condition
  3. Action: Issue Edit
    • Select the Labels field and add in the required label(s)

Pros:

  • working for Jira v7.10
  • easy configuration/maintenance
  • no scripting involved

Cons:

  • update is done after an event trigger
    • this means you have to refresh the page for the update to reflect on the issue if the Trigger is a workflow transition event
  • actor is a fixed user (i.e. the user that update the change is always the same Jira user for each automation, it cannot be the logged in user or reporter etc.)

Thanks! This works :)

Good solution that doesn't require hacks.

This addon allows only 3 rules per project.

This addon allows only 3 rules per project.

Didn't know that, or is it only for Lite version?

I tried on eval and managed to add 4 rules to the same project. Maybe a workaround is to set projects as Global and then specify the project restriction in the Rule's Condition

What JQL did you use? I tried "Linked_Intercom_Conversation IS Not "Blank"" and got an error message. 

As an added option, you could add a second automation to remove the label upon Status change or another trigger. For instance, if the label was used to identify new issues easily, the label could be automatically removed when assigned or when the status changes.

Like Jens Wölke likes this
0 votes
Rodrigo Atlassian Team May 21, 2015

Hi Johnson,

JIRA does not have a built-in feature for that, but I believe you should be able to achieve this with a custom script using the Script Runner plugin.

I've found a script to add labels automatically. Maybe you can customize that script.

https://answers.atlassian.com/questions/56290/auto-assign-labels-based-on-the-user-group

Hope this helps

@Rodrigo Sogari [Atlassian] Thanks for the very quick reply – much appreciated.

Script Runner looks promising but it does not run on Cloud instances. Bummer. Do you have any other suggestions?

ScriptRunner is available on Cloud these days!
Marketplace Link Here

@Rodrigo Sogari [Atlassian] HI

How to add 'Labels' automatically on Transition/State change ( i.e  changing the bug status (Ex) to 'Open' to 'close' state.Does JIRA support for this.

Please Comment.
Thanks 

Jira Automation lite plugin should be able to solve this.

With Scriptrunner, you can add this custom script post-function on the transition Create:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager

def user = ComponentAccessor.jiraAuthenticationContext?.getLoggedInUser()

def labelManager = ComponentAccessor.getComponent(LabelManager)
labelManager.addLabel(user,issue.id, "Your label here", false)

I just set this up on our site with "Project automation" (which I think is now just built into Jira?)

For us I wanted a way to add "to-groom" to all new cases. I ended up with

 

When: Issue created
If: Issue matches JQL "(labels is EMPTY OR (labels != "to-groom" AND labels != "groomed")) AND status != Resolved AND status != Closed"
Then: Edit issue fields: Labels SET "to-groom"

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

225 views 1 2
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you