Created
February 12, 2014 17:21
-
-
Save dirk-thomas/8960189 to your computer and use it in GitHub Desktop.
send Jenkins data points to custom metric at statuspage.io
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
Place the following jar files under /var/lib/jenkins/plugins/groovy/WEB-INF/lib/ | |
* http-builder-0.7.jar | |
* httpclient-4.3.2.jar (httpcomponents-client-4.3.2) | |
* httpcore-4.3.1.jar (httpcomponents-client-4.3.2) | |
* resolver.jar (Xerces.2.11.0) | |
Groovy script: | |
import groovyx.net.http.HTTPBuilder | |
import groovyx.net.http.ContentType | |
import groovyx.net.http.Method | |
def http = new HTTPBuilder("https://api.statuspage.io/v1/pages/PAGE_ID/metrics/METRIC_ID/data.json") | |
http.request(Method.POST, ContentType.JSON) { req -> | |
header = [ | |
Authorization: "OAuth TOKEN" | |
] | |
body = [ | |
data: [ | |
timestamp: 1392168263, | |
value: 23, | |
] | |
] | |
response.success = { resp, json -> | |
println("Success! ${resp.status}") | |
} | |
response.failure = { resp -> | |
println("Request failed with status ${resp.status}") | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment