Does Slack Notification plugin know to autodetect build status?

19 views
Skip to first unread message

Vitaly Karasik

unread,
Apr 2, 2020, 7:40:18 AM4/2/20
to Jenkins Users
Question regarding Slack Notification plugin in declarative pipeline: is there an elegant way to modify color and embed relevant emoji depends on currentBuild.currentResult?
Or I should clone "slackSend" 3 times - for success, unstable and failed build?

Yeikel

unread,
Apr 2, 2020, 12:26:38 PM4/2/20
to jenkins...@googlegroups.com
Not sure if it is the "most elegant way" but I just defined a property for the color and mutated it based on the build status using an if statement. I also have a base message that I modify using the build status and I use the same approach. 

String color= ...
String message = ""
If(started){
color =...
message+= "emoji"
} else if (success){
color=...
}

slackSend(color: color.....
On Thu, Apr 2, 2020, 7:40 AM Vitaly Karasik <linu...@gmail.com> wrote:
Question regarding Slack Notification plugin in declarative pipeline: is there an elegant way to modify color and embed relevant emoji depends on currentBuild.currentResult?
Or I should clone "slackSend" 3 times - for success, unstable and failed build?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/74fae4a9-0820-4784-a5bf-015af8c7cc65%40googlegroups.com.

lesterp

unread,
Apr 3, 2020, 11:58:54 AM4/3/20
to Jenkins Users
There was an excellent post on the Jenkins blog that had some great examples, here:

Vitaly Karasik

unread,
Apr 5, 2020, 2:51:03 AM4/5/20
to Jenkins Users
Yeikel, Lesterp, many thanks!
Reply all
Reply to author
Forward
0 new messages