Jenkins Continuous Improvement

β€œIn a nutshell, Jenkins is the leading open source automation server. Built with Java, it provides hundreds of plugins to support building, testing, deploying and automation for virtually any project.” – From the Jenkins CI web site.

Install Jenkins

On master, install the Jenkins CI master service:

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -ec 'echo deb http://pkg.jenkins-ci.org/debian binary/ >> /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins

Configure Jenkins

Once installed, Jenkins defaults to allow anyone who visits the page to create and run jobs; this is probably not how you want to run in production so we'll fix that with a little configuration.

On client:

  1. Click Manage Jenkins β†’ Configure Global Security
  2. Click Enable Security
  3. Under Access Control choose Jenkins' own user database and un-check Allow users to sign up
  4. Under Authorization choose Project-based Matrix Authorization Strategy
  5. Add our waytta user and check all the boxes then Save
  6. You'll immediately be redirected to a page to set a password, email address and name
  7. Login using waytta and our default password

Create a Job

Our first job is simple, run the /usr/bin/w command on master.

On client:

  1. Click the create new jobs link
  2. In Item name type Run w as a descriptive title
  3. Choose Freestyle project and click OK
  4. On the next page fill in Description with Run the Unix w command
  5. Check Discard Old Builds
  6. Under Build choose Execute shell
  7. Type the letter w in the Command box or fully specify /usr/bin/w
  8. Click Save

Congratulations! You just created your first Jenkins job.

Run Job

Now that we have a job, run it.

On client:

  1. Click Run w in the Name column
  2. Click Build Now in the menu on the left

You may see a Build scheduled notification then a blue dot with a #1 should appear in the Build History pane.

Congratulations! You just ran your first Jenkins job.

Confirm Job

So, how do you know anything actually happened? What does the little blue dot mean?

  1. Click the #1 link under Build History to see the build status for that run
  2. Click Console Output (terminal icon) in the left menu

This is the Console Output of the Run w job which runs the /usr/bin/w Unix command:

Started by user Curry Searle
Building in workspace /var/lib/jenkins/jobs/Run w/workspace
[workspace] $ /bin/sh -xe /tmp/hudson2725330295819146079.sh
+ w
 19:48:05 up  9:17,  1 user,  load average: 0.01, 0.04, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
waytta   pts/0    192.168.1.138    10:33   12:04   3.26s  3.26s -bash
Finished: SUCCESS

Congratulations! You completed this lesson.

Resources