I recently setup Jenkins so I could learn how to use a real CI/CD system. I picked Jenkins because it appears to be the only continuous integration system that will run on illumos (though I didn’t personally look that hard). Setup was more or less a breeze once I realized I shouldn’t use the version packaged in pkgsrc.

What posessed me to install java personally? I want to do my best to mimic the build environment used to build Triton bits, and the Triton repos have Jenkins support out of the box.

Overall, what I’ve learned so far is that CI/CD is ultimately just Makefiles at scale. And that’s really useful to me, since I use makefiles even where I shouldn’t (for example, all of my LaTeX sources are built using make to take care of the hard stuff).

Setup

I created a fabric network for all of Jenkins’ worker nodes, then created a base-64-trunk instance and attached it to the network. It doesn’t have to be big, but the recommendation is at least 10GB of disk space. Pick whatever fits your needs.

From there, I installed java from the pkgin repository, then grabbed the jenkins WAR file via wget, and then used smfgen to generate a custom SMF manifest that’ll launch it.

pkgin in openjdk11
mkdir /opt/jenkins
wget https://get.jenkins.io/war-stable/2.361.1/jenkins.war
smfgen -c devops -d /var/jenkins -g root -u root -i jenkins -l "Jenkins CI" -s "`which java` -Xmx512m -Xms512m -jar /opt/jenkins/jenkins.war --httpPort=8080" -e PATH=$PATH -e JENKINS_HOME=/var/jenkins > /opt/jenkins/jenkins.xml

Here’s the content of that service manifest:

<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!-- 
    Manifest automatically generated by smfgen.
 -->
<service_bundle type="manifest" name="devops-jenkins" >
    <service name="devops/jenkins" type="service" version="1" >
        <create_default_instance enabled="true" />
        <dependency name="dep0" grouping="require_all" restart_on="error" type="service" >
            <service_fmri value="svc:/milestone/multi-user:default" />
        </dependency>
        <exec_method type="method" name="start" exec="/opt/local/bin/java -Xmx512m -Xms512m -jar /opt/jenkins/jenkins.war --httpPort=8080 &amp;" timeout_seconds="10" >
            <method_context working_directory="/var/jenkins" >
                <method_credential user="root" group="root" />
                <method_environment >
                    <envvar name="PATH" value="/usr/local/sbin:/usr/local/bin:/opt/local/sbin:/opt/local/bin:/usr/sbin:/usr/bin:/sbin" />
                    <envvar name="JENKINS_HOME" value="/var/jenkins" />
                </method_environment>
            </method_context>
        </exec_method>
        <exec_method type="method" name="stop" exec=":kill" timeout_seconds="30" >
            <method_context working_directory="/var/jenkins" >
                <method_credential user="root" group="root" />
                <method_environment >
                    <envvar name="PATH" value="/usr/local/sbin:/usr/local/bin:/opt/local/sbin:/opt/local/bin:/usr/sbin:/usr/bin:/sbin" />
                    <envvar name="JENKINS_HOME" value="/var/jenkins" />
                </method_environment>
            </method_context>
        </exec_method>
        <template >
            <common_name >
                <loctext xml:lang="C" >Jenkins CI</loctext>
            </common_name>
        </template>
    </service>
</service_bundle>

From there, ensure you import and enable the service manifest:

svccfg import /opt/jenkins/jenkins.xml
svcadm enable jenkins

Now navigate to the Jenkins UI and complete setup.