Jira Automation related question
Asked by Bhumi Yadav:

I have created a rule, when I close ticket rule checks if Comment section contain any http,https, confluence, jira, or SharePoint link in ticket, If it does then ticket should remain in closed status or if this condition doesn't match then ticket should be in push back to backlog status.   

I don't know why, even I attached confluence link in comment and close the ticket the rule runs and it push back ticket to backlog instead of closed status.

Is there something I'm doing wrong?

![IMG_5011.png](/t5/image/serverpage/image-id/336121i72016F1C1032644C/image-size/large?v=v2&px=999 "IMG_5011.png")

![IMG_5010.png](/t5/image/serverpage/image-id/336117i7844F99162E675E8/image-size/large?v=v2&px=999 "IMG_5010.png")


Answers:
author: Bill Sheboy
body: Hi [@Bhumi Yadav](/t5/user/viewprofilepage/user-id/5546218) -- Welcome to the Atlassian Community!

The smart value {{issue.comments}} is a list of values, each one with structure including the body, author, etc. of *all the comments* : <https://confluence.atlassian.com/automation/jira-smart-values-issues-993924860.html#Jirasmartvaluesissues-issue.commentsissue.comments>

Are you trying to check for the text / links in all possible comments added for the issue, only the last comment, or something else?

Kind regards,  
Bill

comments: author: Bhumi Yadav
body: Yes any links ( for eg if I comment down in ticket:- The task is complete (link) and add any link after it)

then rule should check if there is any link or not in comment section.

dont know I can't I resolve it, not able to write down smart value for it.


author: Bill Sheboy
body: Could the URLs contain mixed case? If so, perhaps force the comments to lower case before comparison.

Or, perhaps try using the match() function with your regular expression in the*first value* to evaluate all comments, and then test if any results are found.

{{issue.comments.body.split(" ").toLowercase().match("(https?://.\*(confluence\|sharepoint)\\.com)")}}


author: Bhumi Yadav
body: So I have a regex

{{issue.comments.body.match("(http\|https)://").size}}

but it didn't work for short links


author: Bill Sheboy
body: Are you using Jira Cloud or Server / Data Center? I believe that may impact the format of the link representation.

You can confirm the representation by writing the comment to the audit log to see the format of the smart link. For example, this is what I see for Jira Cloud in a comment:

```
here is a comment with a URL [https://community.atlassian.com/|https://community.atlassian.com/|smart-link]
```

And so when I tested your expression:

```
{{issue.comments.body.match("(http|https)://").size}}
```

It doubles the count size. Once you have an expression that works, you may want to add the list function distinct at the end to remove duplicates.

As you want this to also work with shortened links, my suggestion is to perform an internet search for example regular expressions to parse URLs, and then update that for your shortened URL syntax. Then test thoroughly.


author: Bhumi Yadav
body: Thanks definitely I'll try it.


author: Nicolas Grossi
body: [@Bhumi Yadav](/t5/user/viewprofilepage/user-id/5546218) Welcome! I think the first condition "does not match" is the responsible for that?

Nicolas

comments: author: Bhumi Yadav
body: [@Nicolas Grossi](/t5/user/viewprofilepage/user-id/676185) It showing IF block condition passed, issue to BACKLOG,

but it should not pass I have confluence link added in comment.   
If I have link in comment then transition issue should CLOSED.

Not sure if my Regex is correct or not.


author: Bhumi Yadav
body: [@Nicolas Grossi](/t5/user/viewprofilepage/user-id/676185)   

When Issue Transistioned to Closed- Chech IF attachment is Empty or Not - If No- Ticket Remains Closed - IF Yes - Check comment if there is any url link present - No URL (then transition the issue to Backlog) - Yes (Ticket remains Closed)


Tags: automation

jira-unknown-hosting-type

new-to-jira

unknown-hosting-type