<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>John Chambers-Malewig</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/john_chambers-malewig/" />
    <link rel="self" type="application/atom+xml" href="http://blogs.perl.org/users/john_chambers-malewig/atom.xml" />
    <id>tag:blogs.perl.org,2009-11-03:/users/john_chambers-malewig//770</id>
    <updated>2011-03-24T06:35:27Z</updated>
    <subtitle>A blog about the Perl programming language</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.38</generator>

<entry>
    <title>Jenkins and Perlbrew - A &quot;where to&quot; guide</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/john_chambers-malewig/2011/03/jenkins-and-perlbrew---a-where-to-guide.html" />
    <id>tag:blogs.perl.org,2011:/users/john_chambers-malewig//770.1588</id>

    <published>2011-03-24T04:41:26Z</published>
    <updated>2011-03-24T06:35:27Z</updated>

    <summary>Jenkins works well when your Java code is based on the build philosophy of maven or ant and tucked nicely in one of the popular source code management repositories. (All your code is versioned, right?!?) Building a newly created project...</summary>
    <author>
        <name>John Chambers-Malewig</name>
        <uri>http://jchambers.dyndns.org:81/</uri>
    </author>
    
        <category term="Jenkins" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="perlbrew" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="perlbrewjenkins" label="perlbrew Jenkins" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/john_chambers-malewig/">
        <![CDATA[<p><a href="http://jenkins-ci.org/">Jenkins</a> works well when your Java code is based on the build philosophy of <a href="http://maven.apache.org/">maven</a> or <a href="http://ant.apache.org/">ant</a> and tucked nicely in one of the popular source code management repositories.  (All your code is versioned, right?!?)  Building a newly created project will retrieve your code and build it with the system default tools; maven, java or ant.<br />
One of the nice features is the additional "tools" you can install and use to build your projects.  Install the 1.6.X version of ant in your node and select it when you create your new project.  You'll see in your build output, a preliminary stage where it will install and execute your build.xml with the selected version.<br />
<big>Wouldn't it be nice to have have that similar functionality with Perl?<br />
</big>Jenkins puts these into a common area under the ${JENKINS_HOME}/tools directory.  We can install our perl versions in the same location.<br />
At this point, I could discuss the philosophical points of system configuration and the benefits of knowing the preferred brand of beer of each of your admins, but I just need to find a solution that keeps me happy and reserves my admin "chips" for another day.  Enter <a href="http://search.cpan.org/dist/App-perlbrew/">perlbrew</a>.<br />
perlbrew out of the box does a fine job of assuming you need to install itself locally, to you home or ~/ directory.  This is ok for your everyday "proof of concept" or a debate on why a module tests just fine on the a development box, but I needed a way to build these puppies in a CI environment.<br />
Let's start with the PERLBREW_HOME environment variable.  A quick definition at the start of my script [see previous posts] would place perlbrew anywhere in the directory structure I have permissions and, from a Jenkins project, I would have permissions to the "tools" directory.<br />
So, in the Jenkins "Environment variables" section set the name PERLBREW_HOME to a value of ${JENKINS_HOME}/tools/perl5<br />
(I know I can export this variable in the shell and don't need to use this section, but I'm lazy.  Trust me for now.)<br />
Now create a job as a "Build a free-style software project" as "Perlbrew Install" and enter the location of my script that you checked into your SCM (you did commit it, didn't you) or just copy the code into the "Execute shell - Command" section.  Maybe some day I'll get this copied to a publicly available site so you won't have so much copying to do...<br />
Now build your job.  You'll have perlbrew installed in a few moments.<br />
The convenience of perlbrew comes about by the sourcing of the rc files in your shell.  The files define some needed variables perlbrew uses to know where to find itself (how existential) and perl versions you've installed.<br />
Now here's the important part.<br />
<ol><br />
	<li>Go back to the Jenkins "Environment variables" section and change the variable name to either:</li><br />
<blockquote><br />
ENV - if you perfer to use sh as your shell<br />
or<br />
BASH_ENV if you prefer bash<br />
</blockquote><br />
	<li>change the value adding /etc/bashrc to the end</li><br />
<blockquote><br />
the full value should look like ${JENKINS_HOME}/tools/perl5/etc/bashrc<br />
</blockquote><br />
</ol><br />
Jenkins uses sh by default but you can change the default SHELL in the "Shell executable" section to "/bin/bash" or wherever your bash exists.<br />
Now when you create a new job, your "Execute shell" build step will source the file and set not only the PATH but will also set PERLBREW_HOME (see it's not gone for good.)<br />
To test this, create a new job with just "env" as the command.<br />
You might want to add "perlbrew -h" to get you ready for future steps.</p>

<p>Wait!  Don't get rid of your "Perlbrew Install" job just yet.  If you run it again, after a few days, you might notice that a new version of perlbrew gets installed right over the top of the old one!  PERLBREW_HOME always points to the location of perlbrew so you'll be able to schedule it to execute @weekly or @monthly.</p>]]>
        
    </content>
</entry>

<entry>
    <title>Perlbrew - Running init after install, automatically (wget option)</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/john_chambers-malewig/2011/03/-wget-httpxrlusperlbrew-sh-perlbrew.html" />
    <id>tag:blogs.perl.org,2011:/users/john_chambers-malewig//770.1587</id>

    <published>2011-03-24T04:04:32Z</published>
    <updated>2011-03-25T03:27:07Z</updated>

    <summary>Following the discussion on Daniel&apos;s Page you can also install perlbrew using wget similar to using curl. wget -O- --no-check-certificate http://xrl.us/perlbrewinstall | \ sh | \ tee perlbrew_install.log | \ grep &quot;bin/perlbrew init&quot; | \ sh &gt; perlbrew_init.log If you...</summary>
    <author>
        <name>John Chambers-Malewig</name>
        <uri>http://jchambers.dyndns.org:81/</uri>
    </author>
    
        <category term="perlbrew" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="perlbrew" label="perlbrew" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/john_chambers-malewig/">
        <![CDATA[<p>Following the discussion on <a href="http://daniel.haxx.se/docs/curl-vs-wget.html">Daniel's Page</a> you can also install perlbrew using <em><strong>wget</strong></em> similar to using curl.</p>

<p>wget -O- --no-check-certificate http://xrl.us/perlbrewinstall | \<br />
sh | \<br />
tee perlbrew_install.log | \<br />
grep "bin/perlbrew init" | \<br />
sh > perlbrew_init.log</p>

<p>If you don't have admin rights on your development box to install <em><strong>curl</strong></em> but do have <em><strong>wget</strong></em> available, this is an alternative to the instructions in the <a href="http://search.cpan.org/dist/App-perlbrew/">perlbrew</a> pod.</p>]]>
        
    </content>
</entry>

<entry>
    <title>Perlbrew - Running init after install, automatically</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/john_chambers-malewig/2011/03/perlbrew---running-init-after-install-automatically.html" />
    <id>tag:blogs.perl.org,2011:/users/john_chambers-malewig//770.1586</id>

    <published>2011-03-24T03:45:14Z</published>
    <updated>2011-03-24T04:25:19Z</updated>

    <summary>gogod&apos;s perlbrew module allows one to perform some simple admin tasks so you don&apos;t need to have root access. After having installed it a few times over the last couple versions, I created a quick script to install and run...</summary>
    <author>
        <name>John Chambers-Malewig</name>
        <uri>http://jchambers.dyndns.org:81/</uri>
    </author>
    
        <category term="perlbrew" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="perlbrew" label="perlbrew" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/john_chambers-malewig/">
        <![CDATA[<p>gogod's <a href="http://search.cpan.org/dist/App-perlbrew/">perlbrew</a> module allows one to perform some simple admin tasks so you don't need to have root access.  After having installed it a few times over the last couple versions, I created a quick script to install and run the init on installation.</p>

<p>The output of the install contains all the info you need.  (I guess this also adds a dependency of not only <em><strong>curl</strong></em> for installation but also <em><strong>grep</strong></em> and <em><strong>tee</strong></em> but they are found on most *nixs anyway.)</p>

<p>curl -L http://xrl.us/perlbrewinstall | \<br />
  sh | \<br />
  tee perlbrew_install.log | \<br />
  grep "bin/perlbrew init" | \<br />
  sh > perlbrew_init.log</p>

<p>In the future, watch for blogs entries as I attempt to create a development environment for perl on <strike>Hudson</strike> <a href="http://jenkins-ci.org/">Jenkins</a>.</p>]]>
        
    </content>
</entry>

</feed>
