Skip to content

Instantly share code, notes, and snippets.

@ThabetAmer
Created January 18, 2020 08:07
Show Gist options
  • Save ThabetAmer/4a01aa6cbabad052b815a63ff9359cfe to your computer and use it in GitHub Desktop.
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
#!/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