Automation Rule |An automation to search some phrases in the comments.body

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

Summary

This article will help in setting up the automation rule to search whether some phrases are part of the comment body or not. For example, You wish to search for the strings: On behalf of test 1 | On behalf of test 2 |On behalf of test 3| On behalf of Test 4 and so on.

In this use case, these phrases are long in list and have some common strings. The approach that includes, defining phrases in the Lookup Table and using them with conditions in the automation rule could be a little overwhelming thus we would suggest using regex to cater for this use case.

Solution

The approach to setup this use case could be :

Trigger: Issue commented

If Add a condition: Advanced compare condition

  • First value: {{issue.comments.last.body}}

  • Condition: contains regular expression

  • Regular expression : (?i)on behalf of (Test 1|Test 2|Test 3|Test 4)

Add Action: Comment on the issue

  • Comment: Found the value

Note

We have included (?i) prior to the string to remove case sensitivity, If you wish to keep the case sensitive for the string please feel free to remove it.

Regex Information:

1 2 3 Since "on behalf of" is common in all the sentences we have kept it outside the (). To check the or string we have defined the strings with pipe "|" (Test 1|Test 2|Test 3|Test 4)

Here is the JSON file of the Automation rule:

1 {"cloud":true,"rules":[{"id":14577038,"clientKey":"fcb18f79-08d6-35bd-9c47-b1e204f45645","name":"Search for the string in the comment body","state":"ENABLED","description":"","authorAccountId":"6362284b01c2ff842c19db70","actor":{"type":"ACCOUNT_ID","value":"557058:f58131cb-b67d-43c7-b30d-6b58d40bd077"},"created":1693475046146,"updated":1693475682384,"trigger":{"id":"314304175","component":"TRIGGER","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.issue.event.trigger:commented","value":{"eventKey":"jira:issue_updated","issueEvent":"issue_commented","eventTypes":[]},"children":[],"conditions":[],"connectionId":null},"components":[{"id":"314304176","component":"CONDITION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{issue.comments.last.body}}","second":"(?i)on behalf of (Test|Example|Try)","operator":"REGEX_CONTAINS"},"children":[],"conditions":[],"connectionId":null},{"id":"314304177","component":"ACTION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.issue.comment","value":{"comment":"Found the value","publicComment":false,"commentVisibility":null,"sendNotifications":true,"addCommentOnce":false},"children":[],"conditions":[],"connectionId":null}],"canOtherRuleTrigger":false,"notifyOnError":"FIRSTERROR","projects":[],"labels":[],"tags":[{"id":41974335,"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"}]}

To export and consume. You can import this automation rule following steps of the document: https://support.atlassian.com/cloud-automation/docs/import-and-export-jira-automation-rules/

Updated on May 31, 2024

Still need help?

The Atlassian Community is here for you.