{"id":848,"date":"2014-08-12T18:00:26","date_gmt":"2014-08-12T18:00:26","guid":{"rendered":"https:\/\/psyphi.net\/blog\/?p=848"},"modified":"2014-08-13T08:53:18","modified_gmt":"2014-08-13T08:53:18","slug":"pushing-jenkins-job-build-statuses-to-geckoboard","status":"publish","type":"post","link":"https:\/\/psyphi.net\/blog\/2014\/08\/pushing-jenkins-job-build-statuses-to-geckoboard\/","title":{"rendered":"Pushing Jenkins Job Build Statuses to Geckoboard"},"content":{"rendered":"<p><a href=\"http:\/\/psyphi.net\/wp-uploads\/2014\/08\/geckoboard.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-849 size-full\" src=\"http:\/\/psyphi.net\/wp-uploads\/2014\/08\/geckoboard-e1407853311591.jpg\" alt=\"geckoboard\" width=\"1032\" height=\"239\" srcset=\"https:\/\/psyphi.net\/wp-uploads\/2014\/08\/geckoboard-e1407853311591.jpg 1032w, https:\/\/psyphi.net\/wp-uploads\/2014\/08\/geckoboard-e1407853311591-300x69.jpg 300w, https:\/\/psyphi.net\/wp-uploads\/2014\/08\/geckoboard-e1407853311591-1024x237.jpg 1024w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/p>\n<p>I\u00c2\u00a0love using <a title=\"Geckoboard\" href=\"https:\/\/www.geckoboard.com\/\" target=\"_blank\">Geckoboard<\/a>. I love using <a href=\"http:\/\/jenkins-ci.org\/\" target=\"_blank\">Jenkins<\/a>. I do have a few issues connecting the two though.<\/p>\n<p>My Jenkins\u00c2\u00a0build cluster sits inside my corporate network and while there is a Jenkins plugin for Geckoboard it will only connect to Jenkins instances it can see on the public internet. I\u00c2\u00a0haven&#8217;t yet found a Geckoboard plugin for Jenkins to push results out through either. One day soon I&#8217;ll be annoyed enough to learn some Java and write one but until then I have a hack.<\/p>\n<p>The core configurations of most of my Jenkins jobs runs\u00c2\u00a0approximately on these lines:<\/p>\n<pre><code>make deb &amp;&amp; scp *deb deb-repo.my.net:\/var\/www\/apt\/incoming\/<\/code><\/pre>\n<p>i.e. build a .deb (for Ubuntu) and if successful, copy and\u00c2\u00a0queue it for indexing by reprepro on my .deb repository server.<\/p>\n<p>Now in Geckoboard I can configure a 1&#215;1 Custom Text widget for PUSH data and publish data to it like so:<\/p>\n<pre><code>curl https:\/\/push.geckoboard.com\/v1\/send\/F639F1AE-2227-11E4-A773-8FE5A58BF7C4 \\\r\n-d \"{\"api_key\":\"AC738FE5A58BF7C4\",\"data\":{\"item\":[{\"text\":\"packagename.deb\",\"type\":0}]}}\"<\/code><\/pre>\n<p>Let&#8217;s make it a little more sustainable. In the main Jenkins configuration I set up a global environment variable called GECKO_APIKEY\u00c2\u00a0with a value of\u00c2\u00a0AC738FE5A58BF7C4. Now the line reads:<\/p>\n<pre><code>curl https:\/\/push.geckoboard.com\/v1\/send\/F639F1AE-2227-11E4-A773-8FE5A58BF7C4 \\\r\n-d \"{\"api_key\":\"$GECKO_APIKEY\",\"data\":{\"item\":[{\"text\":\"packagename.deb\",\"type\":0}]}}\"<\/code><\/pre>\n<p>I know I&#8217;ll need to change the posted data on failure which most like means duplicating some or all of that line so I&#8217;ll extract the widget id too. The job is now configured like:<\/p>\n<pre><code>export WIDGET=F639F1AE-2227-11E4-A773-8FE5A58BF7C4\r\nmake deb &amp;&amp; scp *deb deb-repo.my.net:\/var\/www\/apt\/incoming\/\r\ncurl https:\/\/push.geckoboard.com\/v1\/send\/$WIDGET \\\r\n -d \"{\"api_key\":\"$GECKO_APIKEY\",\"data\":{\"item\":[{\"text\":\"packagename.deb\",\"type\":0}]}}\"<\/code><\/pre>\n<p>But it&#8217;s not yet triggered differently on success or failure, so&#8230;<\/p>\n<pre><code>export WIDGET=F639F1AE-2227-11E4-A773-8FE5A58BF7C4\r\nmake deb &amp;&amp; scp *deb deb-repo.my.net:\/var\/www\/apt\/incoming\/ \u00c2\u00a0&amp;&amp; \\\r\ncurl https:\/\/push.geckoboard.com\/v1\/send\/$WIDGET\u00c2\u00a0\\\r\n -d \"{\"api_key\":\"$GECKO_APIKEY\",\"data\":{\"item\":[{\"text\":\"packagename.deb\",\"type\":0}]}}\" || \\\r\ncurl https:\/\/push.geckoboard.com\/v1\/send\/$WIDGET\u00c2\u00a0\\\r\n -d \"{\"api_key\":\"$GECKO_APIKEY\",\"data\":{\"item\":[{\"text\":\"packagename.deb\",\"type\":1}]}}\"<\/code><\/pre>\n<p>The duplicate URL and packagename.deb are annoying\u00c2\u00a0aren&#8217;t they? A quick look at the Jenkins docs reveals $JOB_NAME has what we want.<\/p>\n<pre><code>export WIDGET=F639F1AE-2227-11E4-A773-8FE5A58BF7C4\r\nexport GECKO_URL=https:\/\/push.geckoboard.com\/v1\/send\/$WIDGET\r\nmake deb &amp;&amp; scp *deb deb-repo.my.net:\/var\/www\/apt\/incoming\/ \u00c2\u00a0&amp;&amp; \\\r\ncurl $GECKO_URL\u00c2\u00a0\\\r\n -d \"{\"api_key\":\"$GECKO_APIKEY\",\"data\":{\"item\":[{\"text\":\"$JOB_NAME PASS\",\"type\":0}]}}\" || \\\r\ncurl $GECKO_URL\u00c2\u00a0\\\r\n -d \"{\"api_key\":\"$GECKO_APIKEY\",\"data\":{\"item\":[{\"text\":\"$JOB_NAME FAIL\",\"type\":1}]}}\"<\/code><\/pre>\n<p>Not too bad.\u00c2\u00a0It even works on Windows without too many\u00c2\u00a0modifications &#8211; &#8220;set&#8221; instead of &#8220;export&#8221;, %VAR% instead of $VAR and a Windows curl binary added to %PATH%.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"font-size: smaller;\">Note: All API keys and Widget Ids have been changed to protect the innocent.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I\u00c2\u00a0love using Geckoboard. I love using Jenkins. I do have a few issues connecting the two though. My Jenkins\u00c2\u00a0build cluster sits inside my corporate network and while there is a Jenkins plugin for Geckoboard it will only connect to Jenkins instances it can see on the public internet. I\u00c2\u00a0haven&#8217;t yet found a Geckoboard plugin for &hellip; <a href=\"https:\/\/psyphi.net\/blog\/2014\/08\/pushing-jenkins-job-build-statuses-to-geckoboard\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Pushing Jenkins Job Build Statuses to Geckoboard&#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,9],"tags":[914,1036,1034,1035,89,664],"class_list":["post-848","post","type-post","status-publish","format-standard","hentry","category-programming","category-sysadmin","category-webdev","tag-continuous-deployment","tag-continuous-integration","tag-dashboards","tag-geckoboard","tag-infographics","tag-jenkins"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/848","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=848"}],"version-history":[{"count":6,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/848\/revisions"}],"predecessor-version":[{"id":855,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/848\/revisions\/855"}],"wp:attachment":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/media?parent=848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/categories?post=848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/tags?post=848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}