This repository has been archived by the owner on Sep 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a new library function trySlackSend that echos the message to the build log if the Slack Notification Plugin is not configured. Signed-off-by: Geoff Levand <geoff@infradead.org>
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Sends a notification to Slack. If the Slack Notification Plugin is not | ||
* configured the the notification will be echoed to the Jenkins build log. | ||
*/ | ||
|
||
def call(Map args) { | ||
Map colorMap = [ | ||
'grey' :'#C0C0C0', | ||
'persian' :'#2020C0', | ||
] | ||
String channel = args.channel ?: '' | ||
String color = args.color ? colorMap.get(args.color, args.color) : 'good' | ||
|
||
try { | ||
slackSend(channel: channel, color: color, message: args.message) | ||
} catch (NoSuchMethodError err) { | ||
echo 'Slack Notification (' + args.color + '): ' + args.message | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
The trySlackSend function sends a notification to Slack. If the Slack | ||
Notification Plugin is not configured the the notification will be echoed to | ||
the Jenkins build log. | ||
|
||
Takes a string parameter 'message' and optional string parameters 'channel' and | ||
'color'. |