Published on 12 April 2012 by
Purpose Jenkins is an extensible, open source continuous integration server.
Module rtyler/jenkins
Puppet Version 2.7+
Platforms Enterprise Linux 5 and 6, Debian 6, Ubuntu

This week’s module helps implement and manage Jenkins CI with Puppet. We all need to test our code when we make changes. Saying so is easy, doing so is a lot more difficult. Jenkins makes testing easier. Every time you make a change, Jenkins will test everything still works. It’s easy to get started with Jenkins by using a Puppet module written by R. Tyler Croy. This module automatically installs the Jenkins software, configures the service, and provides an simple way to add functionality by automatically installing any of the 400+ Jenkins plugins. You should give this module a spin if you’re looking for an easy way to try out Jenkins or puppetize an existing Jenkins server. Install it, classify a node with the jenkins class in the Puppet Enterprise Console and Jenkins is running and ready to do your bidding.

Installing the module

Complexity Easy
Installation Time 5 minutes

Installing the Jenkins module is straightforward. The module is published on the Puppet Forge so we’re able to install it directly onto a Puppet Master system with one command. In this example we’re going to use Puppet Enterprise 2.5 to install the module on our Puppet Master. Then we’ll classify a Ubuntu Lucid node with the jenkins class and see how Puppet automatically brings up the Jenkins console web interface.

In this example we’ve installed Puppet Enterprise 2.5 on a CentOS 6.2 machine. (Note: if you don’t have Puppet Enterprise, you can easily install this module using the puppet-module gem or upgrade to Puppet 2.7.13 or later to get the puppet module subcommand.)

[email protected]:~# puppet module install rtyler-jenkins
Preparing to install into /etc/puppetlabs/puppet/modules ...
Downloading from ...
Installing -- do not interrupt ...
└─┬ rtyler-jenkins (v0.2.2)
  └── puppetlabs-apt (v0.0.2)
[email protected]:~#

Now that we have the Jenkins module installed, we just need to add the jenkins class to the configuration catalog of an agent system. In this example I’m going to use the Puppet Enterprise Console to do this, but you could just as easily accomplish this using a node declaration in your site.pp manifest in Puppet.

First, we’ll add the jenkins class to the Puppet Enterprise Console. To do this we click the “Add Class” button in the bottom left corner of the console, and name it “jenkins”:

Once the jenkins class has been added to the Puppet Enterprise Console we can create a group to associate our Ubuntu Lucid node with the jenkins class. This image shows the “Add group” screen:

Once we click “Create” the jenkins class will be included in the configuration catalog of the Ubuntu Lucid node. Let’s see what this looks like on the Puppet Agent now.

[email protected]:~# puppet agent --test
info: Retrieving plugin
info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/puppet_vardir.rb
info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/facter_dot_d.rb
info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/root_home.rb
info: Caching catalog for pe-ubuntu-lucid.2012-04-09.15837
info: Applying configuration version '1334091722'
notice: /Stage[main]/Jenkins/Package[jre]/ensure: \
  current_value purged, should be 1.7.0 (noop)
notice: Class[Jenkins]: Would have triggered 'refresh' from 1 events
notice: /Stage[main]/Jenkins::Repo::Debian/Apt::Source[jenkins]/\
  Apt::Key[Add key: D50582E6 from Apt::Source jenkins]/\
    Exec[3ae8ac921fb6f9e7a9be3adca21e45c2226e43b2]/returns: \
      executed successfully
notice: /Stage[main]/Jenkins::Repo::Debian/Apt::Source[jenkins]/\
  File[jenkins.list]/ensure: \
    defined content as '{md5}941681fa47a0a1b579f98bce22bbcaf6'
info: /Stage[main]/Jenkins::Repo::Debian/Apt::Source[jenkins]/\
  File[jenkins.list]: Scheduling refresh of Exec[jenkins apt update]
notice: /Stage[main]/Jenkins::Repo::Debian/Apt::Source[jenkins]/\
  Exec[jenkins apt update]: Triggered 'refresh' from 1 events
notice: /Stage[main]/Jenkins::Package/\
  Package[jenkins]/ensure: ensure changed 'purged' to 'present'
notice: Finished catalog run in 150.88 seconds
[email protected]:~#

Once puppet agent finished, the Jenkins service will be available at http://HOSTNAME:8080/ where HOSTNAME is the hostname of the node Puppet configured Jenkins on. You should expect to see something like this:

In the next section we’ll cover some additional resources that make it easier to manage and automate Jenkins plugins.

Resource Overview

The main jenkins class is be the only class you need to add to your node classification. The module contains other classes, but these are automatically managed for you by the jenkins class.

Jenkins is a very extensible CI system. provides over 400 plugins to customize it to your specific needs. The Jenkins module makes it easy to manage these plugins with Puppet by defining the jenkins::plugin resource type.

Jenkins cannot monitor a Git repository for changes by default, but developers and system administrators often need to have their jobs run when they publish changes to a Git repository. Jenkins helps solve this problem by providing a Git plugin allowing Jenkins to automatically clone Git repositories and poll them for changes.

To have Puppet automatically install and manage the Git plugin, declare a jenkins::plugin resource in the nodes configuration catalog. In this example, I’m going to create a new class named site::jenkins_plugins and declare the necessary resource. We’ll then add this new class and see how Puppet automatically manages the service.

Here’s the copy of /etc/puppetlabs/puppet/modules/site/manifests/jenkins_plugins.pp that defines the class:

# = Class: site::jenkins_plugins
#   This class manages the Jenkins plugins we want to use at our site.
# = Requires
#   puppet module install rtyler-jenkins
# = Sample Usage
#   include site::jenkins_plugins
class site::jenkins_plugins {
  # This resource default will ensure the Jenkins service
  # restarts automatically after Puppet configures all plugins.
  Jenkins::Plugin { notify => Class[jenkins::service] }
  # Tell Puppet to configure and manage the Jenkins Git Plugin.
  jenkins::plugin { 'git': }

With this class in place in a manifest we simply need to classify the Lucid system with this site::jenkins_plugin class like we did before with the jenkins class.

First, add the class to the Puppet Enterprise Console:

Then, update the jenkins group to also contain the site::jenkins_plugins class. This will associate nodes in this group with both the jenkins and the site::jenkins_plugins class.

Finally, run puppet agent on the Lucid node to apply the new configuration with the Git plugin resource.

[email protected]:~# puppet agent --test
info: Retrieving plugin
info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/puppet_vardir.rb
info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/facter_dot_d.rb
info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/root_home.rb
info: Caching catalog for pe-ubuntu-lucid.2012-04-09.15837
info: Applying configuration version '1334094999'
notice: /Stage[main]/Jenkins/Package[jre]/ensure: \
  current_value purged, should be 1.7.0 (noop)
notice: /Stage[main]/Site::Jenkins_plugins/Jenkins::Plugin[git]/\
  Group[jenkins]/ensure: created
notice: /Stage[main]/Site::Jenkins_plugins/Jenkins::Plugin[git]/\
  User[jenkins]/gid: gid changed '65534' to 'jenkins'
notice: /Stage[main]/Site::Jenkins_plugins/Jenkins::Plugin[git]/\
  File[/var/lib/jenkins]/group: group changed 'adm' to 'jenkins'
notice: /Stage[main]/Site::Jenkins_plugins/Jenkins::Plugin[git]/\
  File[/var/lib/jenkins/plugins]/group: group changed 'nogroup' to 'jenkins'
notice: /Stage[main]/Site::Jenkins_plugins/Jenkins::Plugin[git]/\
  Exec[download-git]/returns: executed successfully
info: /Stage[main]/Site::Jenkins_plugins/Jenkins::Plugin[git]/\
  Exec[download-git]: Scheduling refresh of Service[jenkins]
info: Jenkins::Plugin[git]: Scheduling refresh of Class[Jenkins::Service]
notice: Class[Jenkins]: Would have triggered 'refresh' from 1 events
info: Class[Jenkins::Service]: Scheduling refresh of Service[jenkins]
notice: /Stage[main]/Jenkins::Service/Service[jenkins]: \
  Triggered 'refresh' from 2 events
notice: Finished catalog run in 11.37 seconds
[email protected]:~#

After running Puppet, we’re able to see the newly installed plugin in the Jenkins console interface.

The Jenkins module would be pretty darn good if all it did was install the package and manage the Jenkins service automatically. In this section we’ve seen that the module puts forth some extra effort and makes it easy to install and activate additional functionality in Jenkins through the use of a Puppet defined resource type. This combination allows you, as a Puppet user, to easily get started with Jenkins and customize it to your specific needs. All with only a few commands and a couple of lines of Puppet.


In this post we walked through installation and use of R. Tyler’s jenkins module, which allows us to automatically run the Jenkins service and manage the Git plugin. With this configuration, we’re ready to start automatically watching our Git repositories for changes and running automated tests after each change. Not only does this module provide an easy and fast way to configure the Jenkins service on RHEL and Ubuntu systems, it provides an easy way to install any of the 400+ Plugins available on

If you’re interested in contributing to the Jenkins module some good features would be the ability to manage jobs using Puppet resources and adding additional platform support. Pull requests are always welcome!

Additional Resources

Share via:
Posted in:

Hi ,
Can you explain how to add user to jenkin using puppet module . I tried adding user , but it is now reflecting in the node(jenkin) .

The content of this field is kept private and will not be shown publicly.

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.