Before starting up, set the environment variable HUBOT_PIPELINE_URL to point to the pipeline url.
Created
February 18, 2013 17:12
-
-
Save bltavares/4978929 to your computer and use it in GitHub Desktop.
Hubot script - Pipeline reporter
This file contains hidden or 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
{ | |
"name": "alfred", | |
"version": "2.2.0", | |
"author": "GitHub Inc.", | |
"keywords": "github hubot campfire bot irc", | |
"description": "A simple helpful Robot for your Company", | |
"licenses": [ | |
{ | |
"type": "MIT", | |
"url": "http://github.com/github/hubot/raw/master/LICENSE" | |
} | |
], | |
"repository": { | |
"type": "git", | |
"url": "http://github.com/github/hubot.git" | |
}, | |
"dependencies": { | |
"hubot": "2.3.2", | |
"hubot-scripts": ">=2.0.8", | |
"optparse": "1.0.3", | |
"hubot-irc": "~0.1.9", | |
"jsdom": "~0.5.0" | |
} | |
} |
This file contains hidden or 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
# Provides project status | |
# | |
# check <query> - Get the status for the first project that partially matches from the pipeline | |
# check <query>! - Get the status for the first project that strict matches from the pipeline | |
jsdom = require("jsdom") | |
module.exports = (robot) -> | |
robot.respond /check ([^!]+)(!?)/i, (msg) -> | |
msg.send "Checking the pipeline, sir" | |
project = msg.match[1] | |
strictMatch = msg.match[2] | |
msg.http(process.env["HUBOT_PIPELINE_URL"]) | |
.get() (err, res, body) -> | |
return msg.send "Failed! " + err if err | |
jsdom.env | |
html: body | |
scripts: ['http://code.jquery.com/jquery-1.9.1.min.js'] | |
(err1, window) -> | |
$ = window.jQuery | |
projects = $("#trunk td.projectname") | |
matcher = if strictMatch then new RegExp("^" + project + "$") else project | |
projectFound = projects.filter(-> $(this).text().match matcher).first() | |
if projectFound.length == 0 | |
return msg.send "Sorry sir, I couldn't find " + project | |
filteredProject = projectFound.parent().find("a:first") | |
status = filteredProject.find("span.tool:first") | |
isBad = !status.hasClass("good") | |
if isBad | |
msg.send "Sir, " + projectFound.text() + " is smelling bad. I am sorry." | |
msg.send filteredProject.attr("href") | |
else | |
msg.send "Sir, everything is pretty with " + projectFound.text() + "#" + status.children().text() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment