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

added pipeline script for Hangouts Chat #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions pipeline-examples/hangoutsChatNotify/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Synopsis
Use a Hangouts Chat webhook to send an arbitrary message.

# Background
Using a combination of groovy and curl from shell, send a message to Hangouts Chat for notifications.
Some of the more friendly groovy http libs like HTTPBuilder are not easily available. However,
we can use groovy's built in json handling to build up the request and ship it to a command
line curl easily enough.

This will require that you configure a webhook integration in Hangouts Chat (not the Jenkins specific configuration.)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import groovy.json.JsonOutput
// Add whichever params you think you'd most want to have
// replace the chatURL below with the hook url provided by
// Hangouts when you configure the webhook
def notifyHangoutsChat(text) {
def chatURL = 'https://chat.googleapis.com/v1/spaces/xxxxxxx/messages?key=API_KEY'
def payload = JsonOutput.toJson([text : text])
sh "curl -X POST ${chatURL} \ -H 'Content-Type: application/json' \ -d '${payload}'"
}