Skip to content

Instantly share code, notes, and snippets.

@ranrubin
Created June 25, 2019 15:13
Show Gist options
  • Save ranrubin/4964fc7d1fa7ff47caf6e50890db091c to your computer and use it in GitHub Desktop.
Save ranrubin/4964fc7d1fa7ff47caf6e50890db091c to your computer and use it in GitHub Desktop.
@Library('Jenkins-Shared-Library-Objects@stateful-advanced')
def httpHandler = getHttpRestHandler("http://myconsul.com:8500") // constructing a HttpRest
def consul = getConsulHandler(httpHandler)
node('NODE') {
try {
String jsonRegisterData = "{ .. }" // A string of whatever data we want in json format
stage("register data") {
consul.register(jsonRegisterData)
}
stage("store some data") {
consul.store("v1/kv/test/1/data", "value1")
consul.store("v1/kv/test/2/data", "value2")
}
stage("list Nodes"){
consul.list_nodes()
}
}
catch(err){
//.. handle
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment