Hi there! Newbie here :)
I'm trying to set up an automation rule that sends comments into a Slack channel when a specific user is mentioned, the assignee or reporter.
I'm using the Advanced compare condition and this is my initial if statement to check if the user is the one commenting. This doesn't seem to work as I would like it (I figured it's me who misunderstood something) because it just passes the first IF statement no matter who comments :)
----
If: Compare two values
Checks if:
First value:
{{issue.comments.author}}
Condition
Does not match regular expression
Regular expression
.*\[~5ecd20a9730ec90c1988740c:.+\].*
----
I have double-checked the ID should match the user.
I tried following these two Questions:
Solved: How to trigger automation action if comment contai... (atlassian.com)
Solved: How to make a rule that triggers an action when a ... (atlassian.com)
This is all of the automation.
First, you're using `does not match` which is generally going to match lots of things. Anything that doesn't match the regular expression.
Also, this regex:
.*\[~5ecd20a9730ec90c1988740c:.+\].*
doesn't contain the accountid: portion of a user mention. Both of the threads you linked used `.*\[accountid:~.+\].*`. The "accountid:" portion is meaningful.
So what I'm trying to achieve with this part of the statement is that whenever this specific user comments on an issue it shouldn't send a slack message. But if anyone else comments, where the user is either a reporter, assignee, or mentioned, a slack message is created. I'm not sure if the way I did it is either the best way or if it's correct.
If there is a better way I'm all ears and eager to learn :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is 5ecd20a9730ec90c1988740c the account id? Jira / Atlassian use a couple of different representations of users. Internal to Jira it uses account ids which are usually of the shape `numbers:letters-numbers-l&n-l&n-l&n`.
You can figure this out by creating a simple rule which sends their account id to the audit log by logging a comment which mentions them:
After that, use that exact account id in the regex:
.*\[~accountid:557057:fdddddd-6633-46a3-9acf-123456789da2\].*
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It seems to be the same AccountID as I tried earlier, although it doesn't seem to match what you described it should look like.
I have tried to update the RegEx with "accountid:...", it still just passes everything. Is there another way I can achieve my goal of not letting it pass a comment from a specific user? Or do you have some other comments on what I do wrong?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are number of points of fundamental confusion seeping into the discussion. I think there is some confusion about what case you're actually testing. In the OP there are two different conditions — one which checks the author and another which looks for user mention. Additionally there is confusion about when to check using equality against a specific value vs when to use a regular expression.
The regular expression that you are using from other threads on the community is for searching comment bodies for user mentions. The leading and trailing .* allows the regular expression to read past the other content in the body. The square bracket [~accountid:{id}] structure is the structure of a user mention.
The screenshot that you've just included seems to be attempting to check a comment author. In that case, you're checking against a smart value, where the ID will just be the identifier with no surrounding square brackets. If you need to check a comment author for a specific person, you don't need a regular expression, you can just use a standard equality check.
General debugging advice: Use the audit log action to print out he value that you're comparing. That will help in determining why the regular expression isn't matching.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for breaking it down into small pieces. That helped me a lot.
You are absolutely right about me having trouble separating when to use regex and when not to :)
We verified that it now works with the user - thank you for your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Niklas Missel,
I'm not sure why you need all those extra things in your regular expression. Mine worked just fine like this:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay, it still doesn't seem to do the trick. The user still gets a slack message when they comment themselves.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Niklas Missel,
How did you get their account ID? As I said, this rule worked just fine for me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Kian Stack Mumo Systems I got it by going to the admin user page --> clicking on the user --> see the Account ID In the URL.
I confirmed the Account ID by following Wwalser's suggestion (See comment below):
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Niklas Missel,
I think you just need the portion located AFTER the "accountid:". When I log just the author of a comment, it does not contain the accountid: segment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Kian Stack Mumo Systems I just tried using my own AccountID (didn't want to bother the user anymore).
Nothing changes; it passes when I comment on an issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ha! I think I have an idea. Let's try this. Update your condition to the following -
{{issue.comments.last.author}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So far so good, it seems to work with my own ID. I'm waiting for the user to try :)
If that's what needed... well you are truly the hero. And I think makes sense why (just writing it out to see if I fully understand); When I used {{issue.comments.author}} it took the author of the first comment and not the latest right?
Will give you an update soon (hopefully good)!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Niklas Missel, it took the authors of EVERY comment. The reason that the first suggestion I made worked for me was that I only logged a single comment, so there was only one value in my list.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That makes sense,.thanks for clarifying.
I verified that it now works with the user - thank you for your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.