Just to revise and update the post from a while back. Not that much has changed, but I figured it would be worth an update.

Build the machine

We need an image to run on:

imgadm import 17c98640-1fdb-11e3-bf51-3708ce78e75a

And we need a machine to run on. Call the file jenkins-ci.json.

{
    "brand": "joyent", 
    "alias": "jenkins-ci", 
    "zonename": "jenkins-ci",
    "domain": "local",
    "max_physical_memory" : "1024",
    "dataset_uuid": "17c98640-1fdb-11e3-bf51-3708ce78e75a",
    "resolvers": [
        "208.67.220.220",
        "208.67.222.222"  
    ],
    "nics": [
        {
          "nic_tag": "admin",  
          "ip": "dhcp"  
        }  
    ]
}

Lets create the image:

vmadm create -f jenkins-ci.json

And once it’s created, you can log in it:

zlogin jenkins-ci

Now lets get started with installing stuff.

Packages to install

Need a few things to install to get things installed prior to get the things up and running.

pkgin in mDNSResponder avahi sun-jdk6 scmgit mercurial subversion nano gcc47 gmake gcc-compiler binutils pkg_alternatives autoconf

This will get us the common source control system, along with the JDK so that we run Jenkins.

The mDNSResponder and avahi will make it easier for us to connect to the box, assuming that you’re client machine is a mac. But, we need to turn them on:

svcadm enable mdnsresponder:default

That way we can can go to jenkins.local instead of using the IP address.

Setting up Jenkins

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. Let’s get Jenkins downloaded.

mkdir /opt/jenkins
cd /opt/jenkins
wget http://mirrors.jenkins-ci.org/war/latest/jenkins.war

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>
                <dependency name='network' grouping='require_all'
                        restart_on='error' type='service'>
                        <service_fmri value='svc:/milestone/network:default' />
                </dependency>
                <dependency name='filesystem' grouping='require_all'
                        restart_on='error' type='service'>
                        <service_fmri value='svc:/system/filesystem/local' />
                </dependency>

                <method_context>
                        <method_credential user='jenkins' group='jenkins' privileges='basic,net_privaddr' />
                        <method_environment>
                                <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' />
                        </method_environment>
                </method_context>

                <!-- 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} --spdy'
                        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>
                <property_group name='startd' type='framework'>
                        <propval name='duration' type='astring' value='child' />
                        <propval name='ignore_error' type='astring' value='core,signal' />
                </property_group>

                <stability value='Evolving' />

                <template>
                        <common_name>
                                <loctext xml:lang='C'>Jenkins Continuous Build Server</loctext>
                        </common_name>
                        <documentation>
                                <doc_link name='hudson.dev.java.net' uri='http://jenkins-ci.org/' />
                        </documentation>
                </template>
        </service>
</service_bundle>

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.

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

Extra Credit

Since I intend to do some Erlang programming, I should set the build server up to handle that.

pkgin in erlang freetds 

And now enable epmd:

svcadm enable epmd:default

Since there will be some deployment activities, the jenkins user will need to be able to SSH into things.

su - jenkins
ssh-keygen -t rsa

We also need to setup git.

git config --global user.name "Jenkins"
git config --global user.email "jenkins@example.org"

Once completed, you can type exit and get back to the root shell.



Published

16 October 2013

Category

devops

Tags