Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Jira automation: How to add an emoji to Slack message when issue conditions are met?

Jenni
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 2, 2022

Hello,

I have Jira Automation script that sends message to Slack when issues with certain conditions are created.

However, I'd want to add a Slack emoji to the message whenever the issue is Blocker by priority.

Currently my automation script has the following line:
Priority: {{if(priority(Blocker))}}:blocker:{{/}} *{{priority.name}}*

Which, hopefully would print ":blocker: Blocker" when it's a blocker, and otherwise just the name of the priority, such as "Normal". For clarification, :blocker: is the name of the emoji I'm trying to call on Slack.

Is the condition correct? So far it doesn't seem to be working.

1 answer

1 vote
Mykenna Cepek
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.
February 3, 2022

Well, that wasn't as trivial as it looked to solve.    :-|

I'll start with the solution:

Priority: {{#if(equals(issue.priority.name,"1-Urgent"))}}:exclamation: {{/}}{{issue.priority.name}}

which produces in Slack, in our environment:

Screen Shot 2022-02-03 at 8.12.57 AM.png

HOWEVER, we have renamed our Status names to use a numeric prefix (so they will sort correctly by priority always). So in your case, of course, you'll want to use "Blocker" instead.

- - - - - - -

Here's why this ended up being non-trivial to solve:

  • The documentation today (here) for the the smart value conditional is, IMHO, wrong. Specifically, the required '#' is missing from many of their examples. I will submit feedback to Atlassian about that. It may be fixed by the time you read this.
  • The OP use of "if(priority(Blocker))" was a red-herring, more wish than actual automation. The correct way to access the priority of an issue in automation is with {{issue.priority}}. Full documentation on how to access issue fields is here.
  • One might have hoped that using "issue.priority" would have worked, as each priority has a numeric code. But "equals(issue.priority,3)" did not work, even if I quoted the 3. I plan to report this to Atlassian as a bug.

Note: I don't like having to rely on priority.name, as names can change (as I did once in our Jira instance, when adding the numeric prefixes). Relying on names could be considered brittle.

In our case, the internal priority numbers don't always match the prefixes used for priority names, as illustrated below. So I'd probably use priority.name in our rules for maximum clarity. Note how helpful it was to use the Audit Log action to confirm the actual values for the priority field:

Screen Shot 2022-02-03 at 8.22.20 AM.png

Screen Shot 2022-02-03 at 8.22.14 AM.png

Jenni Järvinen February 4, 2022

Thank you for your message! My workaround for this was to do branched conditions with JQL checks for what the priority is, and then have customised Slack message for each priority with corresponding emojis. Yes, it was more work but in the end it was clearer than dealing with conditional logic.

I'll keep this in mind though! The "Log action" was new to me, I need to try that.

Mykenna Cepek
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.
February 11, 2022

Since your original question was "Is the condition correct?", and I believe I answered it, would you be willing to accept my answer? That's important feedback, especially for Community Leaders. Thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events