Monday, December 22, 2014

Setting up a Continuous Integration Environment with Jenkins and Docker PART 3 Jenkins Job Setup

In part three of my continuous integration project I'll be completing the Jenkins setup.  I will show how to create a new job, install plugins, and setup credentials to connect to the Git repository we created in Part 2. 

Lets return to the Jenkins server. We previously installed the Java run time environment but we didn't install the JDK development environment.  You can skip this step if your project is not a Java project. 

Step 1) Install the JDK we forgot when creating the Jenkins server> yum list available  | grep java-1.7
java-1.7.0-openjdk.x86_64          1:       updates
java-1.7.0-openjdk-demo.x86_64     1:       updates
java-1.7.0-openjdk-devel.x86_64    1:       updates
java-1.7.0-openjdk-javadoc.noarch  1:       updates
java-1.7.0-openjdk-src.x86_64      1:       updates

> yum install java-1.7.0-openjdk-devel.x86_64
... lots of output ...
Is this ok [y/N]: y

Step 2) Lets not forget git
> yum install git
... lots of output ...
Is this ok [y/N]: y

Step 3) Create the SSH key pair for the Jenkins user.
The yum install of Jenkins sets the Jenkins user shell to /bin/false, thus  is unable to su directly to the jenkins user. Running the following command will generated the ssh key pair for the Jenkins user.

> sudo -u jenkins ssh-keygen

Add the Git repository server to the knows_hosts file for the Jenkins user, answer yes to the question. 

> sudo -u jenkins ssh git@
The authenticity of host ' (' can't be established.
RSA key fingerprint is 7c:e6:3d:18:c1:0a:6e:f6:1d:7c:96:f4:f5:c3:da:a5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (RSA) to the list of known hosts.
Last login: Thu Dec 18 13:57:18 2014 from

Step 4) Add some plugins to Jenkins
First lets navigate to our Jenkins instance, then select;  
       manage Jenkins --> --> Manage Plugins --> Available Tab
Select the following Plugins.

  • Git Plugin
  • Git Client Plugin
  • Git Parameter Plugin
  • git-notes Plugin
  • git tag message Plugin
  • Green Balls "Changes Hudson/Jenkins to use green balls instead of blue for successful builds
Select Download now and install after restart

STEP 5) Setup Credentials.

Select Credentials

Select Add Credentials

Select Global Credentials

Select SSH Username with private key, then paste the Private key you created above into the Key field.

STEP 6) Jenkins Configure System
Return to Jenkins HOME then Select Manage Jenkins --> Configure System.

       a) Scroll down and add a JDK installation.
Give it a name, then set the JAVA_HOME location (/usr/lib/jvm/java1.7.0-openjdk.x86_64)

       b) Add a Maven installation.

       c) Add a Git Installation

Step 7) Create a Jenkins job
Since every project will be different I will leave it up to you to configure your Jenkins job to compile and package your app. I will be revisiting this in a future post when I create the Docker Image.

No comments:

Post a Comment