Last active
December 29, 2015 01:59
-
-
Save tonyklawrence/7596920 to your computer and use it in GitHub Desktop.
Dashing Teamcity Widget
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
class Dashing.Teamcity extends Dashing.Widget | |
@accessor 'state', Dashing.AnimatedValue | |
onData: (data) -> | |
if data.status | |
$(@get('node')).attr 'class', (i,c) -> c.replace /\bstatus-\S+/g, '' | |
$(@get('node')).addClass "status-#{data.status}" |
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
<h1 class="title" data-bind="title"></h1> | |
<h2 class="state" data-bind="state"></h2> | |
<p class="more-info" data-bind="moreinfo | raw"></p> | |
<p class="updated-at" data-bind="updatedAtMessage"></p> |
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
require 'net/http' | |
require 'nokogiri' | |
teamcity = 'host:port' | |
build1 = 'bt1111' | |
build2 = 'bt2222' | |
build1 = 'bt3333' | |
SCHEDULER.every '5s' do | |
send_event('teamcity-build1', stateOf(teamcity, build1)) | |
send_event('teamcity-build2', stateOf(teamcity, build2)) | |
send_event('teamcity-build3', stateOf(teamcity, build3)) | |
end | |
def stateOf(teamcity, buildId) | |
doc = Nokogiri::XML(Net::HTTP.get(URI(teamcity + '/guestAuth/app/rest/builds/buildType:(id:' + buildId + '),running:any'))) | |
running = doc.xpath('//running-info/@percentageComplete') | |
status = doc.xpath('//build/@status').text() == 'SUCCESS' ? 'ok' : 'warning' | |
moreinfo = doc.xpath('//build/statusText').text().partition(';').first() | |
if running.empty? | |
if status == 'ok' | |
{ state: 'Ok', status: status, moreinfo: moreinfo } | |
else | |
{ state: 'Broke', status: status, moreinfo: moreinfo } | |
end | |
else | |
{ state: running.text() + '%', status: status, moreinfo: moreinfo } | |
end | |
end |
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
// ---------------------------------------------------------------------------- | |
// Sass declarations | |
// ---------------------------------------------------------------------------- | |
$background-color: #00bb00; | |
$value-color: #fff; | |
$title-color: rgba(255, 255, 255, 0.7); | |
$moreinfo-color: rgba(255, 255, 255, 0.7); | |
// ---------------------------------------------------------------------------- | |
// Widget-number styles | |
// ---------------------------------------------------------------------------- | |
.widget-teamcity { | |
background-color: $background-color; | |
.title { | |
color: $title-color; | |
} | |
.value { | |
color: $value-color; | |
} | |
.more-info { | |
color: $moreinfo-color; | |
} | |
.updated-at { | |
color: rgba(0, 0, 0, 0.3); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment