Skip to content

Instantly share code, notes, and snippets.

@boundvariable
Created July 18, 2013 01:57
Show Gist options
  • Save boundvariable/6026138 to your computer and use it in GitHub Desktop.
Save boundvariable/6026138 to your computer and use it in GitHub Desktop.
raspberrypi, ledborg, coffeescript, jenkins...
http = require 'http'
fs = require 'fs'
fiveMinutes = 300000
springGreen = '021'
magenta = '202'
olive = '110'
buildStatus =
host: '<YOUR_HOST>'
auth: '<YOUR_AUTH>'
port: 80
path: '/jenkins/api/json'
method: 'GET'
updateBuildLight = ->
console.log 'Updating...'
http.get buildStatus, (res) ->
res.setEncoding 'utf8'
data = []
res.on 'data', (chunk) -> data.push chunk
res.on 'end', ->
jobs = JSON.parse(data).jobs
test = (jobs.filter (job) -> job.name.indexOf('Test') > 1)[0]
color = switch test.color
when 'blue' then springGreen
when 'red' then magenta
else olive
console.log "Build is #{test.color}"
fs.writeFile '/dev/ledborg', color, (err) ->
if err then console.log 'LED failed'
updateBuildLight()
setInterval updateBuildLight, fiveMinutes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment