Skip to content

Instantly share code, notes, and snippets.

@simonista
Last active December 10, 2015 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonista/4394675 to your computer and use it in GitHub Desktop.
Save simonista/4394675 to your computer and use it in GitHub Desktop.
# - fail.png => http://cl.ly/image/183e0Z3L181f
# - pass.png => http://cl.ly/image/233w153f3o2C
# - add `.build-icon { border: none; }` to your theme css
images =
fail: 'http://f.cl.ly/items/3W0B3C1l3u3D0w231y2y/fail.png'
pass: 'http://f.cl.ly/items/1g153P1F302c1h1F0T0P/pass.png'
bind 'line', (line) ->
message = $(line).find '.message'
regex = /●\s?(.+) (?:Build)?\s*(Succeeded|FAILED)\s*(?:\w+:(\d*))?\s*(?:in (\d+) mins)?\s*●\s*(?:(\w+)\s*●)?\s*(?:(.+)\s*●)?\s*(https?:.*)\s*●/
matches = message.text().match regex
return unless matches
idx = 1 # 0 is the whole thing
buildType = matches[idx++]
success = matches[idx++]
patchset = matches[idx++]
time = matches[idx++]
user = matches[idx++]
gitMsg = matches[idx++]?.trim()
hudsonURL = matches[idx++]?.trim()
icon = if success == "Succeeded" then "pass" else "fail"
message.html ""
image = $ "<img/>",
src: images[icon]
class: "build-icon"
image.appendTo message
space = $ "<span/>"
space.append " "
space.appendTo message
build = $ "<span/>"
build.append "#{user} ➜ " if user
build.appendTo message
hudson = $ "<a/>",
href: hudsonURL
hudson.append(gitMsg or buildType)
hudson.appendTo message
whichBuild = $ "<span/>"
whichBuild.append " [#{buildType}" if gitMsg
whichBuild.append ":#{patchset}" if patchset
whichBuild.append "]" if gitMsg
whichBuild.appendTo message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment