Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rocketSend function #56

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Requests OpenShift to start build from the specified build config and waits for

Runs the OWASP dependency-check tool.

### rocketSend

Sends message to the specified WebHook.

## Groovy source files

### DockerHub
Expand Down
22 changes: 22 additions & 0 deletions vars/rocketSend.groovy
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"
}
}
34 changes: 34 additions & 0 deletions vars/rocketSend.txt
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 : -->
Loading