-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73e9ea0
commit 5f1b605
Showing
2 changed files
with
69 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,32 @@ | ||
final ROCKET_ALIAS = "Jenkins" | ||
|
||
def void call(String webHook, String message, String channel = null, String avatar = null, Boolean rawMessage = true) { | ||
Map data = [:] as Map | ||
data['alias'] = ROCKET_ALIAS | ||
data['text'] = message | ||
data['rawMessage'] = rawMessage | ||
|
||
if (channel != null) { | ||
data['channel'] = channel | ||
} | ||
|
||
if (avatar != null) { | ||
data['avatar'] = avatar | ||
} | ||
|
||
def returnCode = sh(returnStatus: true, script: | ||
''' | ||
curl | ||
-X POST "${webHook}" | ||
-H "Content-Type: application/json" | ||
--data "${groovy.json.JsonOutput.toJson(data)}" | ||
--fail ' | ||
''' | ||
) | ||
|
||
if (returnCode != 0) { | ||
error("RocketChat notification failed!") | ||
} else { | ||
echo "RocketChat notification sent successfully" | ||
} | ||
} |
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,37 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<p> | ||
Part of <code>@Library('jenkins-pipeline-shared-libraries')</code> | ||
</p> | ||
<dl> | ||
<dt> | ||
<code id="rocketSend">rocketSend(webHook:String, message:String, channel:String=null, avatar:String=null, rawMessage:Boolean=true):void</code> | ||
</dt> | ||
<dd> | ||
<p> | ||
Publish message at chat.puzzle.ch | ||
<br /> | ||
Example call: | ||
<br> | ||
<code>rocketSend("https://chat.puzzle.ch/hooks/../..", "Build Successful", "general", "https://chat.puzzle.ch/emoji-custom/success.png", true)</code> | ||
</p> | ||
<ul> | ||
<li> | ||
<b>webHook</b> - WebHook Url | ||
</li> | ||
<li> | ||
<b>message</b> - Content of the Rocket Chat message | ||
</li> | ||
<li> | ||
<b>channel</b> - Channel used in Rocket Chat | ||
</li> | ||
<li> | ||
<b>avatar</b> - Avatar image used in Rocket Chat | ||
</li> | ||
<li> | ||
<b>rawMessage</b> - Message should be sent as raw text | ||
</li> | ||
</ul> | ||
</dd> | ||
</dl> | ||
<!-- vim: set ft=html : --> | ||
<!-- code: set language=html : --> |