{"id":391,"date":"2011-09-14T14:15:11","date_gmt":"2011-09-14T14:15:11","guid":{"rendered":"http:\/\/psyphi.net\/blog\/?p=391"},"modified":"2011-09-14T14:18:41","modified_gmt":"2011-09-14T14:18:41","slug":"jenkins-dashboard","status":"publish","type":"post","link":"https:\/\/psyphi.net\/blog\/2011\/09\/jenkins-dashboard\/","title":{"rendered":"A Simple Continuous Integration (Jenkins) Dashboard"},"content":{"rendered":"<p>I had 15 minutes today to produce a wall-mounted-screen-compatible dashboard for showing the latest build statuses from our Jenkins continuous integration manager. It&#8217;s written in Perl and uses a few CPAN modules &#8211; <a href=\"http:\/\/search.cpan.org\/~grantm\/XML-Simple\/\" title=\"XML::Simple\" target=\"_blank\">XML::Simple<\/a>, <a href=\"http:\/\/search.cpan.org\/~gaas\/libwww-perl\/\" title=\"libwww-perl\" target=\"_blank\">LWP::Simple<\/a> and <a href=\"http:\/\/search.cpan.org\/~roode\/Readonly\/\" title=\"Readonly\" target=\"_blank\">Readonly<\/a>.<\/p>\n<p>This is what it looks like:<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-393 aligncenter\" title=\"ci-hud\" src=\"http:\/\/psyphi.net\/wp-uploads\/2011\/09\/ci-hud.png\" alt=\"\" width=\"716\" height=\"461\" \/><\/p>\n<p>and here&#8217;s the code:<\/p>\n<pre>#!\/usr\/local\/bin\/perl -T\r\nuse strict;\r\nuse warnings;\r\nuse XML::Simple;\r\nuse LWP::Simple qw(get);\r\nuse Carp;\r\nuse English qw(-no_match_vars);\r\nuse Readonly;\r\n\r\nReadonly::Scalar our $CI      =&gt; q[http:\/\/my.ci.server\/rssLatest];\r\nReadonly::Scalar our $COLUMNS =&gt; 6;\r\n\r\nmy $str     = get($CI);\r\nmy $xml     = XMLin($str);\r\nmy @entries = map { $xml-&gt;{entry}-&gt;{$_} } sort keys %{$xml-&gt;{entry}};\r\n\r\nprint &lt;&lt;\"EOT\" or croak qq[Error printing: $ERRNO];\r\nContent-type: text\/html\r\n\r\n&lt;html&gt;\r\n &lt;head&gt;\r\n  &lt;title&gt;Continuous Integration HUD&lt;\/title&gt;\r\n  &lt;meta http-equiv=\"refresh\" content=\"120; url=$ENV{SCRIPT_NAME}\"\/&gt;\r\n  &lt;style type=\"text\/css\"&gt;\r\n.stable { background-color: green }\r\n.unstable { background-color: yellow }\r\n.broken { background-color: red }\r\ntable { margin: 0 auto; }\r\na { font-size: bigger; text-decoration: none; color: black; }\r\n  &lt;\/style&gt;\r\n  &lt;script src=\"http:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.6.4\/jquery.min.js\"&gt;&lt;\/script&gt;\r\n  &lt;script type=\"text\/javascript\"&gt;\r\n\\$(document).ready(redraw);\r\n\\$(window).resize(redraw);\r\n\r\nfunction redraw() {\r\n   \\$('tr').height((\\$(window).height()-60)\/\\$('tr').size());\r\n   \\$('td').width((\\$(window).width()-60)\/\\$('tr').first().find('td').size());\r\n}\r\n  &lt;\/script&gt;\r\n &lt;\/head&gt;\r\n &lt;body&gt;\r\nEOT\r\n\r\nprint qq[&lt;table&gt;\\n] or croak qq[Error printing: $ERRNO];\r\nwhile(scalar @entries) {\r\n  print qq[ &lt;tr&gt;\\n] or croak qq[Error printing: $ERRNO];\r\n  for my $j (1..$COLUMNS) {\r\n    my $entry = shift @entries;\r\n    if(!$entry) {\r\n      last;\r\n    }\r\n\r\n    my $title = $entry-&gt;{title};\r\n    my $class = q[stable];\r\n    $class    = ($title =~ \/unstable\/smx) ? 'unstable' : $class;\r\n    $class    = ($title =~ \/broken\/smx)   ? 'broken'   : $class;\r\n    $title    =~ s{\\s+[(].*?$}{}smx;\r\n\r\n    my $href = $entry-&gt;{link}-&gt;{href};\r\n    print qq[  &lt;td class=\"$class\"&gt;&lt;a href=\"$href\"&gt;$title&lt;\/a&gt;&lt;\/td&gt;] or croak qq[Error printing: $ERRNO];\r\n  }\r\n  print qq[ &lt;\/tr&gt;\\n] or croak qq[Error printing: $ERRNO];\r\n}\r\nprint qq[&lt;\/table&gt;\\n] or croak qq[Error printing: $ERRNO];\r\n\r\nprint &lt;&lt;'EOT' or croak qq[Error printing: $ERRNO];\r\n &lt;\/body&gt;\r\n&lt;\/html&gt;\r\nEOT<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I had 15 minutes today to produce a wall-mounted-screen-compatible dashboard for showing the latest build statuses from our Jenkins continuous integration manager. It&#8217;s written in Perl and uses a few CPAN modules &#8211; XML::Simple, LWP::Simple and Readonly. This is what it looks like: and here&#8217;s the code: #!\/usr\/local\/bin\/perl -T use strict; use warnings; use XML::Simple; &hellip; <a href=\"https:\/\/psyphi.net\/blog\/2011\/09\/jenkins-dashboard\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;A Simple Continuous Integration (Jenkins) Dashboard&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[11,17],"tags":[424,664],"class_list":["post-391","post","type-post","status-publish","format-standard","hentry","category-programming","category-sysadmin","tag-dashboard","tag-jenkins"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/comments?post=391"}],"version-history":[{"count":9,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/391\/revisions"}],"predecessor-version":[{"id":401,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/391\/revisions\/401"}],"wp:attachment":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/media?parent=391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/categories?post=391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/tags?post=391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}