Hello,
I have a following script that lists issues in Slack message depending on issue priority:
*{{issue.summary}}* has been completed *({{Perforce Branch.value}} {{Platform Options.value}} {{Build exe.value}}*).
*CL:* {{Revision}}
*Link:* <{{issue.url}}|{{issue.key}}>
*Tester:* {{initiator.displayName}}
*Results:*
:blocker: *Blocker*
{{#issue.issuelinks.outwardIssue}}
{{#if(equals(priority.name, "Blocker"))}}
* <{{url}}|{{key}}> - {{summary}}
{{/}}{{/}}
:bangbang: *Critical*
{{#issue.issuelinks.outwardIssue}}
{{#if(equals(priority.name, "Critical"))}}
* <{{url}}|{{key}}> - {{summary}}
{{/}}{{/}}
:large_red_square: *Major*
{{#issue.issuelinks.outwardIssue}}
{{#if(equals(priority.name, "Major"))}}
* <{{url}}|{{key}}> - {{summary}}
{{/}}{{/}}
:large_green_circle: *Normal*
{{#issue.issuelinks.outwardIssue}}
{{#if(equals(priority.name, "Normal"))}}
* <{{url}}|{{key}}> - {{summary}}
{{/}}{{/}}
:large_blue_circle: *Minor*
{{#issue.issuelinks.outwardIssue}}
{{#if(equals(priority.name, "Minor"))}}
* <{{url}}|{{key}}> - {{summary}}
{{/}}{{/}}
However, I'm not sure how to add to the script when there is, say, no Minor issues? If there is nothing to print, currently there's just empty space after the heading - but I'd like it to say something like ":tada: No new Minor issues found!" Not just sure what IF or NOT condition I should be referring to?
Pinging @Mykenna Cepek as you've provided great answers before! :)
Wow, my first shout-out right in the OP. I'm humbled, @Jenni !
So, one option is to use nested #if statements to suppress an entire section:
{{#if(equals(0,0))}} {{#if(equals(1,1))}} hello {{/}} {{/}}
But that's starting to get excessive and hard to read.
Something else to consider would be to pull out most of the #if logic into conditionals in the rule before the Slack action, and build variables for the output. Then when creating the slack message:
{{#if(not(myvar1.equals("x")))}}
{{myvar1}}
{{myvar2}}
{{/}}
or whatever.
Note that I've not had good success with defining blank variables in automation. That's why my example above checks against "x". There may also be issues with newline in variables.
So the pseudocode for one section might be like:
I hope that makes sense.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.