Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Could we create an automation which assigns a label to an epic based on a ticket name ?

Romain Lavie October 17, 2022

Hi everyone, 

The CONTEXT is the following one :

There is an epic which contains several issues.

Each issues are named specifically like for example "ABC-12" or "HD-7238".

The issues "ABC-12" and "HD-7238" are related to the epic W.

There is always a dash "-" in the issue name.

GOAL:

Inside an automation I would like to write a function that for each issue assigns to the related epic, a label with the value of the X characters before the dash in the issue name.

So for the issue "ABC-12", the epic W will be assigned the label "ABC" and for the issue "HD-7238" the epic W will be assigned the label "HD".

Would it be possible to help me build the JSON program to complete this JIRA automation or would it be possible to point me to the relevant JSON functions to create such a program?

Below is an image of the structure of the automation I am thinking of using.

Many thanks in advance for your help and your time that would be very valuable!

image.png

3 answers

1 accepted

1 vote
Answer accepted
Yvan Martin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 25, 2022

Hi @Romain Lavie

Developer from Automation here.

"Each issues are named specifically like for example "ABC-12" or "HD-7238"."

In terms of adding that label from the issue smart value you were close, but the name of an issue is considered the summary and not the key. So using the issue name would be more like {{triggerIssue.summary.split("-").first}}, you would also use triggerIssue since you are trying to edit the epic using a branch. I would also consider adding some conditions to ensure the issue has - in the first place as well, but it's not necessary. In terms of adding a label, it's easiest to use the "Edit issue" action, select "..." and on the append section you can type in smart values like the above.

I've attached below and example that should do the job, the other thing you'll need to think about is the triggering action. In this example I used on issue created, you could also possibly use issue updated, or field value trigger depending on what triggering action you want the rule to run with. As a tip when trying out a rule, manual triggers can be useful. 

Screen Shot 2022-10-26 at 12.06.57 am.pngScreen Shot 2022-10-26 at 12.09.58 am.png

Hope this help, if you require further help with your rule you can get in touch with support: https://support.atlassian.com/

Cheers.

Romain Lavie October 26, 2022

Hi @Yvan Martin thank you so much for your help ! Very helpful to deep dive into JIRA and understand how automations work !

1 vote
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 17, 2022

Hi @Romain Lavie 

Context is key for automation rules...

  • Outside of a branch, the smart value {{issue}} refers to the triggering issue
  • Inside of a branch, {{issue}} refers to the the branched to issue

When you want to reference the triggering issue(s) inside of a branch, please try this one:

{{triggerIssue}}

Kind regards,
Bill

Romain Lavie October 18, 2022

Hi @Bill Sheboy thank you very much for your help!

Like Bill Sheboy likes this
0 votes
Romain Lavie October 17, 2022
Here is the code that I wrote, but I couldn't figured out why it didn't work :

{
"fields": {
"labels": [{
"add": {{issue.key.split("-").first}}
}],
}
}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events