So, you have a running SmartOS installation, what are you going to do with it?

For starters, let’s put a running instance of Jenkins on it. It’s almost as simple as it sounds, but not really.

First and foremost lets get the latest image that Joyent has provided.

imgadm import 3766d58c-d777-11e1-89c1-4fa1b8ed5c1e

This image is as fresh as they come, at least at the time of writing.

We’ll need a new virtual machine to run everything on, so use the following template:

	"brand": "joyent", 
	"alias": "jenkins-ci", 
	"zonename": "jenkins-ci",
	"domain": "local",
	"max_physical_memory" : "768",
	"dataset_uuid": "9012a9c2-f15d-11e1-a33a-afaec53ebde9",
	"resolvers": [
	"nics": [
		  "nic_tag": "admin",  
		  "ip": "dhcp"  

Call the file jenkins.json and then:

vmadm create -f jenkins.json

Wait for a few minutes and you have a new VM!

vmadm list

Go ahead and zlogin jenkins-ci and you should be logged into the machine.

We’ll need to create a new group and user to run jenkins under, since we shouldn’t run jenkins as the root user.

groupadd jenkins
useradd -g jenkins -d /var/jenkins -s /bin/bash -m -c "Jenkins CI" jenkins
passwd -N jenkins
passwd jenkins

Ok, now for some hard work. We’ll need Java to run Jenkins, and place for the war file to live and the war file itself.

pkgin in sun-jdk6-6.0.26 
mkdir /opt/jenkins
cd /opt/jenkins

The Java runtime will take a while to download and it will ask questions before it installs, but the rest is straight forward.

Done? Finally!

All services under SmartOS need a mainfest file to run. This is a feature of how services are handled under Solaris, which SmartOS derives from.

Create a file called jenkins.smf.xml in /opt with the following content:

<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='jenkins'>
        <service name='application/jenkins' type='service' version='1'>

                <create_default_instance enabled='false' />

                <!-- Only one instance of Hudson should ever run per server -->
                <single_instance />

                <dependency name='multi-user-server' type='service'
                        grouping='require_all' restart_on='none'>
                        <service_fmri value='svc:/milestone/multi-user-server' />
                <dependency name='network' grouping='require_all'
                        restart_on='error' type='service'>
                        <service_fmri value='svc:/milestone/network:default' />
                <dependency name='filesystem' grouping='require_all'
                        restart_on='error' type='service'>
                        <service_fmri value='svc:/system/filesystem/local' />

                        <method_credential user='jenkins' group='jenkins' privileges='basic,net_privaddr' />
                                <envvar name='PATH'
                                        value='/usr/bin:/usr/sbin:/opt/local/bin:/opt/local/sbin' />
                                <envvar name='JAVA_HOME' value='/opt/local/lib/jvm/default-jdk/jre' />
                                <envvar name='JENKINS_HOME' value='/var/jenkins/home' />

                <!-- Set the JENKINS_HOME env variable, and run the war file in /opt/jenkins/jenkins.war -->
                <exec_method type='method' name='start'
                        exec='/opt/local/bin/java -Xmx512m -server -jar /opt/jenkins/jenkins.war --webroot=%{jenkins_webroot} --httpPort=%{jenkins_http_port}'
                        timeout_seconds='30' />
                <exec_method type='method' name='stop' exec=':kill -TERM'
                        timeout_seconds='60' />

                <property_group name='application' type='application'>
                        <propval name='jenkins_webroot' type='astring'
                                value='/var/jenkins/web' />
                        <propval name='jenkins_http_port' type='astring'
                                value='80' />
                        <propval name='log_dir' type='astring' value='/var/jenkins/log' />
                <property_group name='startd' type='framework'>
                        <propval name='duration' type='astring' value='child' />
                        <propval name='ignore_error' type='astring' value='core,signal' />

                <stability value='Evolving' />

                                <loctext xml:lang='C'>Jenkins Continuous Build Server</loctext>
                                <doc_link name='' uri='' />

Now, let’s import the manifest file and get this baby started!

svccfg -v import /opt/jenkins.smf.xml
svcadm enable jenkins
svcs | grep jenkins

You should see as being online!

I won’t go into details about configuring Jenkins, since there is plenty of documentation already available for that.

Just a few things that are worth mentioning.

If you would like to use git on the server, you can install it via:

pkgin in scmgit-

There are also plugins available to make life easier using Jenkins with Github. You can install the following plugins:


19 July 2012