Skip to content

Instantly share code, notes, and snippets.

@dirk-thomas
Created February 12, 2014 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dirk-thomas/8960189 to your computer and use it in GitHub Desktop.
Save dirk-thomas/8960189 to your computer and use it in GitHub Desktop.
send Jenkins data points to custom metric at statuspage.io
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