Installing Jenkins and Java in CentOS6.5 and Creating the Freestyle Project Job for Shell command execution

In this tutorial we will learn, how to install openJDK and Jenkins in CentOS6.5 and how to configured jobs in Jenkins.

We need:
1. CentOS6.5 Installed in your system
2. Have root level access
3. Internet access in your system for downloading the required files

Installing the java-1.7.0-openjdk

For installing the java you have to type the bellow command:

[root@dev]# yum install java-1.7.0-openjdk

[root@dev]# java -version
[root@dev]# java -version
java version "1.7.0_95"
OpenJDK Runtime Environment (rhel- u95-b00)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)

Installation of a stable version of Jenkins

wget -O /etc/yum.repos.d/jenkins.repo
rpm --import
yum install jenkins

service jenkins start/stop/restart
chkconfig jenkins on

Start the Jenkins
service jenkins start

Verify Jenkins is running or not?

[root@dev]# ps -ef | grep jenkins
root      3912  1939  0 20:17 pts/0    00:00:00 grep jenkins
jenkins   8331     1  5 19:41 ?        00:01:58 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/
lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon --httpPort=8080 --ajp13
Port=8009 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20

Note: I'm running CentOS with vagrant and virtual box so I have to do the tunneling for access the Host and port of Jenkins by putty. 

Open the any browser and type the URL of Jenkins


Jenkins in CentOS with OpenJDK

Create the Jobs:

Click on the New Item
Type the Item Name First-job-in-jenkins
Select the Freestyle project
In configuration page come all the way down

Select Execute Shell from Add build step and type

ps -fe | grep jenkins

Jenkins-in-centos-java-home-page-jobs-execute shell

Email notification from Add post build action
Type the email Recipients 

Click on the Save

Now this configuration will save 

[root@dev]# vi /var/lib/jenkins/jobs/First-job-in-jenkins/config.xml

<?xml version='1.0' encoding='UTF-8'?>
      <strategy class="hudson.tasks.LogRotator">
  <scm class="hudson.scm.NullSCM"/>
      <command>ps -ef | grep jenkins</command>
    <hudson.tasks.Mailer plugin="mailer@1.11">

About Jenkins Installation in CentOS and Job creation!

This is all about how to install Jenkins and Java in CentOS6.5 with job creation in Jenkins.


No comments:

Post a Comment

Please provide your input, it will honer for me...