-
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.
Merge pull request #56 from puzzle/rocket-send
add rocketSend function
- Loading branch information
Showing
3 changed files
with
60 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
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,22 @@ | ||
def void call(String webHook, String message, String avatar = null, Boolean rawMessage = true) { | ||
Map data = [:] as Map | ||
data['text'] = message | ||
data['rawMessage'] = rawMessage | ||
|
||
if (avatar != null) { | ||
data['avatar'] = avatar | ||
} | ||
|
||
def curlCommand = 'curl ' + | ||
' -X POST "' + webHook + '" ' + | ||
' -H "Content-Type: application/json" ' + | ||
' --data \'' + groovy.json.JsonOutput.toJson(data) + '\' ' | ||
|
||
def returnCode = sh(script: curlCommand, returnStatus: true) | ||
|
||
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,34 @@ | ||
<?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, avatar:String=null, rawMessage:Boolean=true):void</code> | ||
</dt> | ||
<dd> | ||
<p> | ||
Publish message at chat.puzzle.ch. The channel destination is disabled for the integration. Therefore you need to create the Webhook first. | ||
<br /> | ||
Example call: | ||
<br> | ||
<code>rocketSend("https://chat.puzzle.ch/hooks/../..", "Build Successful", "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>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 : --> |