Site icon SimplivLearning Blog

What is Jenkins CI and How to install Jenkins in Amazon Cloud EC2.

Introduction to Continuous integration:

Jenkins is a Continuous Integration (CI) server or tool which is written in java platform. Continuous Integration is a practice of running our tests on a non-developer machine automatically every time we push new code into the source git repository. JENKINS is an open-source free download and install tool.

You can visit here to learn CI/CD with Devops tools in detail.

Let’s take a deep dive and learn more about the fundamentals of Continuous Integration.

Build: Build jobs are at the heart of the Jenkins build process. Simply put, you can think of a Jenkins build job as a particular task or step in your build process. This may involve simply compiling your source code and running your unit tests.

Advantages of Jenkins:

 Install Jenkins on AWS EC2 Cloud

Jenkins is a self-contained Java-based program, ready to run out-of-the-box, with packages for Windows, Mac OS X and other Unix-like operating systems. As an extensible automation server, Jenkins can be used as a simple CI server or turned into the continuous delivery hub for any project.

 Prerequisites to Install Jenkins:

You can visit here to understand more information about CI/CD pipeline with AWS Cloud

Steps to Launch Ec2 instance:

Steps to login Ec2 instance:

  1. Download putty and puttygen from “ https://www.putty.org” and install.

For an Amazon Linux AMI, the user name is ec2-user.

•For a RHEL AMI, the user name is ec2-user or root.

•For an Ubuntu AMI, the user name is ubuntu or root.

•For a Centos AMI, the user name is centos.

•For a Fedora AMI, the user name is ec2-user.

•For SUSE, the user name is ec2-user or root.

How to install Java

We will be using open Java. To get the latest version, visit http://openjdk.java.net/install/

We can search and install java in Ec2 server by using below command:

# yum search java

# yum install java-1.8*

# yum -y install java-1.8.0-openjdk

Let’s confirm Java Version and set the java home

# java -version

The output should be something like this:

java version “1.8.0_181”

OpenJDK Runtime Environment (amzn-2.6.14.8.80. amzn1-x86_64 u181-b00)

OpenJDK 64-Bit Server VM (build 24.181-b00, mixed mode)

find /usr/lib/jvm/java-1.8* | head -n 3

#JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64

export JAVA_HOME

PATH=$PATH: $JAVA_HOME

# To set it permanently update your .bash profile

source ~/.bash profile

STEPS TO INSTALL JENKINS AND CONFIGURE

You can install Jenkins using the rpm or by setting up the repo. We will set up the repo so that we can update it easily in the future. Get the latest version of Jenkins from https://pkg.jenkins.io/redhat-stable/

yum -y install wget

wget -O /etc/yum.repos.d/Jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

rpm –import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

yum -y install Jenkins

Start Jenkins

Ubuntu:

# sudo systemctl start Jenkins

Linux:

# sudo service Jenkins start

# To check whether it started successfully, run:

systemctl status Jenkins or service Jenkins status

You should see something similar to this:

Accessing Jenkins

By default, Jenkins runs at port 8080. You can access Jenkins at

http://YOUR-SERVER-PUBLIC-IP:8080

                        Let’s create Jenkins Job step by step:

To create a Jenkins project, we need to access Jenkins Dashboard with our Server IP address and port 8080 “http://localhost:8080”. Enter user credentials to login.

STEP1:

STEP2:

After login into Jenkins Dashboard,  click on “CREATE NEW ITEM” on the right side.

STEP 3:

Now, we need enter our project name as “Jenkins”.

Choose “Free style project”

Click on “OK”.

STEP 4:

Add description of the Project.

STEP 5:

Now, we need configure Git repository. Visit https://github.com/jenkins/firstproject.git. You will find it under “source code management”.

For this Jenkins and git integration, we need to install git plugin in Jenkins.

Go to manage Jenkins-à manage plugins

Search for Git plugin and install plugin.

After installing Git plugin, we need to add Jenkins URL in Git webhooks.

Go to repository settings and click on webhook and add Jenkins URL.

Click on webhooks and add webhook Jenkins URL and save.

Now we can integrate Git with Jenkins to push changes from Git to Jenkins for our project.

STEP6:

Now we need to provide all the details, since it’s time to build the code.  The settings under the build section will help you build the code at the time you want.

STEP 7:

Since we are done with Build, we need to check console output.

Conclusion:

Jenkins is a “DevOps” open-source project written in Java that runs on Windows, macOS, and other Unix-like operating systems. It’s free, community-supported, and might be your first-choice tool for continuous integration. Primarily deployed on-premises, Jenkins can run on cloud servers as well.

Compared to other CI tools price, integration and use cases, it  supports all operating systems.

Hope this article will help to learn Jenkins.

Written by Jagadeesh

Exit mobile version