Create an issue only when a specific Label is added to a Jira issue

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

This article helps in creating a Jira issue based on the label field value via automation. An example of a rule has been detailed below. The conditions in the rule can be customized as per requirement.

Solution

Trigger: When a Field value is updated

Fields to monitor when changed: Labels

Change type: Value added

For: Create issue | Edit issue

Condition: Advanced compare condition

First Value: {{fieldChange.fromString}}

Condition: Does not contain

Second Value: test

Condition: Advanced compare condition

First Value: {{fieldChange.toString}}

Condition: contains

Second Value: test

1st condition explanation

This condition would check whether value changes from the field "Labels" doesnot contain value "test"

Condition: Advanced compare condition

First Value : {{fieldChange.fromString}}

Condition : Does not contain

Second Value : test

2nd condition explanation

This condition would check whether value changed to the field "Labels" contains value "test"

Condition: Advanced compare condition

First Value : {{fieldChange.toString}}

Condition : contains

Second Value : test

The first advanced compare condition ensures that the label being checked is not already a part of the "labels" field and the second advanced compare condition checks that the label being checked is a new label that's added to the label field.

Sharing snippet for reference and automation rule to import:

1 {"cloud":true,"rules":[{"id":13801634,"clientKey":"f9177e80-7502-3077-9e03-f70cde71a16f","name":"Label>create issue","state":"ENABLED","description":"","authorAccountId":"6362284b01c2ff842c19db70","actor":{"type":"ACCOUNT_ID","value":"557058:f58131cb-b67d-43c7-b30d-6b58d40bd077"},"created":1690794106692,"updated":1690887717638,"trigger":{"id":"297381402","component":"TRIGGER","parentId":null,"conditionParentId":null,"schemaVersion":2,"type":"jira.issue.field.changed","value":{"changeType":"VALUE_ADDED","fields":[{"value":"labels","type":"field"}],"actions":["create","edit"]},"children":[],"conditions":[],"connectionId":null},"components":[{"id":"297381403","component":"CONDITION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{fieldChange.fromString}}","second":"test","operator":"NOT_CONTAINS"},"children":[],"conditions":[],"connectionId":null},{"id":"297381404","component":"CONDITION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{fieldChange.toString}}","second":"test","operator":"CONTAINS"},"children":[],"conditions":[],"connectionId":null},{"id":"297381405","component":"ACTION","parentId":null,"conditionParentId":null,"schemaVersion":10,"type":"jira.issue.create","value":{"operations":[{"field":{"type":"ID","value":"summary"},"fieldType":"summary","type":"SET","value":"test"},{"field":{"type":"ID","value":"description"},"fieldType":"description","type":"SET","value":null},{"field":{"type":"ID","value":"project"},"fieldType":"project","type":"SET","value":{"value":"current","type":"COPY"}},{"field":{"type":"ID","value":"issuetype"},"fieldType":"issuetype","type":"SET","value":{"type":"COPY","value":"current"}}],"advancedFields":null,"sendNotifications":false},"children":[],"conditions":[],"connectionId":null}],"canOtherRuleTrigger":false,"notifyOnError":"FIRSTERROR","projects":[],"labels":[],"tags":[{"id":38231552,"tagType":"IS_RULE_UPDATED","tagValue":"true"}],"ruleScope":{"resources":["ari:cloud:jira::site/7bbd0f61-9cf7-46a8-a02c-5d635b174db8"]},"ruleHome":{"ruleLifeCycleHome":{"locationARI":"ari:cloud:jira-servicedesk::site/7bbd0f61-9cf7-46a8-a02c-5d635b174db8"},"ruleBillingHome":{"locationARI":"ari:cloud:jira-servicedesk::site/7bbd0f61-9cf7-46a8-a02c-5d635b174db8"}},"writeAccessType":"UNRESTRICTED","collaborators":[],"billingType":"NORMAL"}]}

NOTE

Copy the above JSON code in a file and save it as .json. Import it in JIRA to import the above rule.

Advanced compare condition

There is an alternate approach to setup this use case as shared in the example below:Automation Rule ExampleThe limitation observed with this approach is that it creates the issue when another label has been removed from the Labels field even though no changes were made to the label being checked. To overcome ths challenge, the rule suggested at the start of the KB can be utilized.

Updated on July 11, 2024

Still need help?

The Atlassian Community is here for you.