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.

  • Test: Testing in DevOps is automated within the build pipeline to ensure that the applications are deployable.
  • “continuous integration” and application delivery.
  • Git:  Git is a Distributed Version Control tool that is used to store different versions of a file in a remote or local repository. It is used to track changes in the source code.

Advantages of Jenkins:

  • Continuous integration
  • Open-source software 
  • Installation is easier in all operating systems
  • Ant, maven, docker, and many others can be used in it
  • Builds can be made based on user requirements
  • Git, maven, bitbucket can be easily linkup with it
  • It has more than 1000+ plugins to make work easier
  • Easy to integrate with Aws Ec2 with plugin.

 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:

  • EC2 RHEL 7.x Instance
    • With Internet Access
    • Security Group with Port 8080 open for Internet
    • If we are using AWS Ec2 for Jenkins, setup port 8080 should be open in security groups in INBOUND Rules.
  • Java v1.8.x
  • Should have at least basic knowledge on Linux commands, Git commands.
  • Go to Ec2 Dashboard and click on Network security and choose currently Running Ec2 security group.

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

Steps to Launch Ec2 instance:

  • Login to AWS console. Select Ec2 launch Instance.
  • Select Type of Operating system Amazon Ec2 instance. Choose “Amazon Linux AMI”.
  • Select Amazon Ec2 instance as per your project needs.
  • Check details VPC, Ec2 Region and leave another options default. Click Next.
  • Select storage options by default. It will give 8GB and we can increase volume space.
  • Review detail and create Keypair or we can select Existing key pair for Ec2. click on Launch instance.

Steps to login Ec2 instance:

  1. Download putty and puttygen from “ https://www.putty.org” and install.
  • Open puttygen and convert .pem file to .ppk file and save as a private key file.
  • Launch putty and use below usernames to login as per our Ec2 instance Types.

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.

  • Open putty and set Ec2 instance Public Ip and check port number 22.
  • Next, click on the + button next to the SSH field to expand this section. Then click on Auth (which stands for authenticate) and enter the name of your private key file (i.e. the ppk file) where it says Private key file for authentication (if you click on browse you can easily search for the directory where you have stored it).

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
  • Password Location:/var/lib/Jenkins/secrets/initial admin password
  • Wait for plugins installation  to complete.
  • Create username and password and click “save and continue”.
  • On the next page, you will be asked to set the URL for the Jenkins instance. The URL field will be populated with an automatically generated URL.
  • Complete the setup confirm the URL by clicking on the Save and Finish button.

                        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.

  • Click on “Add build step”
  • Select “execute windows or shell command”
  • Now execute project code in shell.
  • click on save and apply.
  • Build code

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

46 COMMENTS

  1. Thanks for writing this content. Step by step procedure with the screenshots made is simple to understand. Please make a content on CI/CD,Docker, GitHub and more useful stuff.

  2. Great article,

    Helped understanding me Devops basics and what is Jenkins and installations on cloud. Need more articles on other tools.

  3. Great work..Very informative and easy to understand. I basically have zero knowledge about cloud computing but your article gave me a very good understanding..Please make a blog on docker and Amazon web services…Keep up the good work…Thanks

  4. I’m impressed, I need to say. Actually rarely do I encounter a blog that’s each educative and entertaining, and let me tell you, you might have hit the nail on the head. Your idea is excellent; the problem is one thing that not sufficient people are speaking intelligently about. I am very completely happy that I stumbled across this in my search for something relating to this.

  5. There are definitely a variety of details like that to take into consideration. That may be a nice point to convey up. I offer the ideas above as general inspiration however clearly there are questions just like the one you carry up where an important thing shall be working in sincere good faith. I don?t know if finest practices have emerged around issues like that, however I am positive that your job is clearly identified as a good game. Each boys and girls feel the impact of only a second’s pleasure, for the rest of their lives.

  6. Very great post. I just stumbled upon your blog and wished to say that I have really enjoyed surfing around your weblog posts. After all I’ll be subscribing for your rss feed and I’m hoping you write once more very soon!

    • Hey , thanks for checking out the blog. I’m glad you liked it. I’ll be publishing the next blog in the series very soon. Cheers!

    • Hello there! Thanks for your feedback, we are glad you found our blog useful.

      You can definitely share this blog on you twitter, you can also check our courses on Simpliv for your devops learning requirements.

  7. Hello, you used to write fantastic, but the last several posts have been kinda boring?K I miss your super writings. Past several posts are just a little bit out of track! come on!

    • Hey , thanks for checking out the blog. I’m glad you liked it. I’ll be publishing the next blog in the series very soon. Please subscribe to our blog to stay posted. Cheers!

  8. I like this weblog so much, saved to favorites. “Respect for the fragility and importance of an individual life is still the mark of an educated man.” by Norman Cousins.

  9. Good ?V I should certainly pronounce, impressed with your website. I had no trouble navigating through all tabs and related info ended up being truly simple to do to access. I recently found what I hoped for before you know it at all. Reasonably unusual. Is likely to appreciate it for those who add forums or something, web site theme . a tones way for your client to communicate. Nice task..

  10. Have you ever thought about writing an e-book or guest authoring on other sites? I have a blog based on the same topics you discuss and would really like to have you share some stories/information. I know my readers would appreciate your work. If you’re even remotely interested, feel free to send me an e-mail.

  11. hello there and thank you for your info – I have definitely picked up something new from right here. I did however expertise some technical points using this web site, as I experienced to reload the site a lot of times previous to I could get it to load correctly. I had been wondering if your web host is OK? Not that I am complaining, but sluggish loading instances times will very frequently affect your placement in google and can damage your high quality score if advertising and marketing with Adwords. Well I’m adding this RSS to my email and can look out for much more of your respective exciting content. Ensure that you update this again very soon..

  12. Woah! I’m really loving the template/theme of this website. It’s simple, yet effective. A lot of times it’s challenging to get that “perfect balance” between user friendliness and visual appeal. I must say you’ve done a superb job with this. Also, the blog loads extremely quick for me on Chrome. Excellent Blog!

  13. It is perfect time to make some plans for the future and it’s time to be happy. I have read this post and if I could I wish to suggest you few interesting things or suggestions. Maybe you can write next articles referring to this article. I desire to read even more things about it!

LEAVE A REPLY

Please enter your comment!
Please enter your name here