Created
July 18, 2013 01:57
-
-
Save boundvariable/6026138 to your computer and use it in GitHub Desktop.
raspberrypi, ledborg, coffeescript, jenkins...
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
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