-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.groovy
41 lines (35 loc) · 1.22 KB
/
test.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//import com.dtolabs.rundeck.plugins.notification.NotificationPlugin
import groovy.json.JsonOutput
def sendMessage(type, color, configuration, execution) {
//with no args, there is a "configuration" and an "execution" variable in the context
//sendMessage(type, color, configuration, execution)
json_payload = JsonOutput.toJson( [
title: "Rundeck Job Notification",
summary: "Rundeck Job Notification",
text: "${type} job: #${execution.id}: ${execution.project} ${execution.status} at ${execution.dateEnded}",
themeColor: "${color}",
potentialAction: [
[
"@context": "http://schema.org",
"@type": "ViewAction",
name: "Seed job execution",
target: ["${execution.href}"]
]
]
])
return json_payload
}
configuration = [
'webhook_url': '<URL HERE>'
]
execution = [
'id': 'xyz',
'project': 'projectx',
'status': 'succes',
'dateEnded': '2017-05-05'
]
type = "START"
color = "228B22"
json_payload = sendMessage(type, color, configuration, execution)
process = [ 'bash', '-c', "curl -v -k -X POST -H \"Content-Type: application/json\" -d '${json_payload}' ${configuration.webhook_url}" ].execute().text
print process