Created
January 18, 2020 08:07
-
-
Save ThabetAmer/4a01aa6cbabad052b815a63ff9359cfe to your computer and use it in GitHub Desktop.
Jenkins Groovy function to return an emoji from a pool based on the build status, can be used with Slack notifications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env groovy | |
/** | |
* Returns an emoji from a pool based on the build status, can be used with Slack notifications | |
* @author [email protected] | |
* @since Jenkins 2.204.1 | |
* @param String status default 'success' | |
* @return String emoji | |
* | |
*/ | |
def getEmoji(String status = "success") { | |
def emojis = status == "success" ? | |
[":v:", ":ok_hand:", ":clap:", ":man_dancing:", ":trollface:", | |
":rocket:", ":ghost:", ":thumbsup:", ":tada:", ":confetti_ball:"] | |
: | |
[":thumbsdown:", ":scream_cat:", ":triumph:", ":rage:", ":bangbang:", | |
":see_no_evil:", ":hear_no_evil:", ":speak_no_evil:", ":gun:"] | |
def RandomIndex = (new Random()).nextInt(emojis.size()) | |
return emojis[RandomIndex] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment