{"id":125,"date":"2010-02-26T18:11:20","date_gmt":"2010-02-26T18:11:20","guid":{"rendered":"http:\/\/psyphi.net\/blog\/?p=125"},"modified":"2010-02-26T19:18:26","modified_gmt":"2010-02-26T19:18:26","slug":"configuring-hudson-continuous-integration-slaves","status":"publish","type":"post","link":"https:\/\/psyphi.net\/blog\/2010\/02\/configuring-hudson-continuous-integration-slaves\/","title":{"rendered":"Configuring Hudson Continuous Integration Slaves"},"content":{"rendered":"<p>Roughly this time last year I set up <a title=\"Hudson-CI\" href=\"http:\/\/hudson-ci.org\/\" target=\"_blank\">Hudson<\/a> at the office to do Oxford Nanopore&#8217;s continuous integration builds. It&#8217;s been a pleasure to roll-out the automated-testing work-ethic for developers and (perhaps surprisingly) there&#8217;s been less resistance than I expected. Hudson is a great weapon in the arsenal and is dead easy to set up as a master server. This week though I&#8217;ve had to do something new &#8211; configure one of our product simulators as my first Hudson slave server. Again this proved to be a doddle &#8211; thanks Hudson!<\/p>\n<p>My slave server is called &#8220;device2&#8221; &#8211; Here&#8217;s what I needed to set up on the master (ci.example.net).<\/p>\n<p>&#8220;Manage Hudson&#8221; =&gt; &#8220;Manage Nodes&#8221; =&gt; &#8220;New Node&#8221; =&gt; node name = &#8220;device2&#8221;, type is &#8220;dumb slave&#8221; =&gt; number of executors = 1, remote fs root = &#8220;\/home\/hudson\/ci&#8221;, leave for tied jobs only, launch by JNLP.<\/p>\n<p>Then on device2:<\/p>\n<pre><code>adduser hudson\r\nsu hudson\r\ncd\r\nmkdir ci\r\ncd ci\r\nwget http:\/\/ci.example.net\/jnlpJars\/slave.jar<\/code><\/pre>\n<p>Made a new file \/etc\/init.d\/hudson-slave with these contents:<\/p>\n<pre><code>#!\/bin\/bash\r\n#\r\n# Init file for hudson server daemon\r\n#\r\n# chkconfig: 2345 65 15\r\n# description: Hudson slave\r\n\r\n. \/etc\/rc.d\/init.d\/functions\r\n\r\nRETVAL=0\r\nNODE_NAME=\"device2\"\r\nHUDSON_HOST=ci.example.net\r\nUSER=hudson\r\nLOG=\/home\/hudson\/ci\/hudson.log\r\nSLAVE_JAR=\/home\/hudson\/ci\/slave.jar\r\n\r\npid_of_hudson() {\r\n    ps auxwww | grep java | grep hudson | grep -v grep | awk '{ print $2 }'\r\n}\r\n\r\nstart() {\r\n    echo -n $\"Starting hudson: \"\r\n    COMMAND=\"java -jar $SLAVE_JAR -jnlpUrl \\\r\n        http:\/\/${HUDSON_HOST}\/computer\/${NODE_NAME}\/slave-agent.jnlp \\\r\n        2&gt;$LOG.err \\\r\n        &gt;$LOG.out\"\r\n    su ${USER} -c \"$COMMAND\" &amp;\r\n    sleep 1\r\n    pid_of_hudson &gt; \/dev\/null\r\n    RETVAL=$?\r\n    [ $RETVAL = 0 ] &amp;&amp; success || failure\r\n    echo\r\n}\r\n\r\nstop() {\r\n    echo -n \"Stopping hudson slave: \"\r\n    pid=`pid_of_hudson`\r\n    [ -n \"$pid\" ] &amp;&amp; kill $pid\r\n    RETVAL=$?\r\n    cnt=10\r\n    while [ $RETVAL = 0 -a $cnt -gt 0 ] &amp;&amp;\r\n        { pid_of_hudson &gt; \/dev\/null ; } ; do\r\n        sleep 1\r\n        ((cnt--))\r\n    done\r\n\r\n    [ $RETVAL = 0 ] &amp;&amp; success || failure\r\n    echo\r\n}\r\n\r\nstatus() {\r\n    pid=`pid_of_hudson`\r\n    if [ -n \"$pid\" ]; then\r\n        echo \"hudson (pid $pid) is running...\"\r\n        return 0\r\n    fi\r\n    echo \"hudson is stopped\"\r\n    return 3\r\n}\r\n\r\n#Switch on called\r\ncase \"$1\" in\r\n    start)\r\n        start\r\n        ;;\r\n    stop)\r\n        stop\r\n        ;;\r\n    status)\r\n        status\r\n        ;;\r\n    restart)\r\n        stop\r\n        start\r\n        ;;\r\n    *)\r\n        echo $\"Usage: $0 (start|stop|restart|status}\"\r\n        exit 1\r\nesac\r\n\r\nexit $RETVAL<\/code><\/pre>\n<pre><code>chkconfig --add hudson-slave\r\nchkconfig hudson-slave on\r\nservice hudson-slave start<\/code><\/pre>\n<p>and that&#8217;s pretty much all there was to it &#8211; refreshing the node-status page on the hudson master showed the slave had registered itself, then reconfiguring one of the existing jobs to be tied to the &#8220;device2&#8221; slave immediately started assigning jobs to it. Tremendous!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Roughly this time last year I set up Hudson at the office to do Oxford Nanopore&#8217;s continuous integration builds. It&#8217;s been a pleasure to roll-out the automated-testing work-ethic for developers and (perhaps surprisingly) there&#8217;s been less resistance than I expected. Hudson is a great weapon in the arsenal and is dead easy to set up &hellip; <a href=\"https:\/\/psyphi.net\/blog\/2010\/02\/configuring-hudson-continuous-integration-slaves\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Configuring Hudson Continuous Integration Slaves&#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":[17],"tags":[217,220,218,219],"class_list":["post-125","post","type-post","status-publish","format-standard","hentry","category-sysadmin","tag-ci","tag-configuration","tag-hudson","tag-testing"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/125","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=125"}],"version-history":[{"count":12,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/125\/revisions"}],"predecessor-version":[{"id":136,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/posts\/125\/revisions\/136"}],"wp:attachment":[{"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/media?parent=125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/categories?post=125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/psyphi.net\/blog\/wp-json\/wp\/v2\/tags?post=125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}