Skip to content

Instantly share code, notes, and snippets.

@colebrumley
Created December 11, 2015 18:22
Show Gist options
  • Save colebrumley/c9f97d9970e314b99e85 to your computer and use it in GitHub Desktop.
Save colebrumley/c9f97d9970e314b99e85 to your computer and use it in GitHub Desktop.
Hubot Coffeescript
module.exports = (robot) ->
rdBaseURL = "https://ops.enteon.io:8443/"
rdUUIDs =
dev_restart: 'd9e1371b-1489-4e10-832e-e244d449e617'
u = rdBaseURL + "api/14/job/"+rdUUIDs.dev_restart+"/run"
enterReplies = ['Bork.', 'Bork bork bork bork bork', 'Bork? Bork?! Youre not looking at the big picture!']
leaveReplies = ['Peace out, bruh!', 'F all this jazz...', 'I, uh, have to go move something from my trunk...']
robot.enter (res) ->
res.send res.random enterReplies
robot.leave (res) ->
res.send res.random leaveReplies
robot.topic (res) ->
res.send "#{res.message.text}? That's a Paddlin'"
robot.hear /I like pie/i, (res) ->
res.emote "makes a freshly baked pie"
robot.respond /restart (.*) in dev/i, (res) ->
app = escape(res.match[1])
res.send("OK, I'll ask Rundeck to restart #{app}...")
data = JSON.stringify({argString: "-name #{app}"} )
robot.http(u)
.header('Content-Type' , 'application/json')
.header('X-Rundeck-Auth-Token','top secret token')
.header('Accept','application/json').post(data) (err, rsp, body) ->
if err
res.send "Awww... #{err}"
return
try
jdata = JSON.parse body
catch error
res.send "Ran into an error parsing JSON :( #{body}"
return
res.send "OK boss, I started the jerb! (#{jdata.permalink})"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment