Jenkins Installation and Set-Up

Samiksha Ojha
BYJU’S Exam Prep Engineering
8 min readOct 3, 2019

Jenkins is an open-source automation server, a java tool that contains a lot of plugins which helps to improve its performance and mainly helps to perform the continuous integration processes. It is an application that requires a web server for automation and allows uninterrupted integration and delivery of projects without consideration of the work platform.

The advantages of using Jenkins are as follows :

  1. It has higher usability for building and testing software projects.
  2. The main motive for using Jenkins is to help the developers in the integration of the changes in the project as fast as possible.
  3. It allows continuous integration and will always be installed on a server where the central build will take place.
  4. It offers the feature of continuously delivering the software by integrating it with a large number of testing and deployment technologies.
  5. The basic advantage is to help organizations to accelerate their software development processes through automation.
  6. Moreover, all the software development life cycle processes are part of Jenkins namely (build, documentation, testing, packaging, staging, and deployment).

Working Procedure

Consider an example :

  1. A developer checks its source code.
  2. Jenkins picks up the changed source code and triggers a build.
  3. The output of the build gets available in the dashboard of Jenkins.

Continuous Integration-

  1. In continuous integration, each and every change made in the source code is built.
  2. The most important requirement of continuous integration is plugins.
  3. It allows detecting errors at an early stage.
  4. It helps to increase the development process.

Example :

Nokia shifted from nightly build (code is pulled only at night) to continuous integration.

The architecture of Jenkins :

The above figure explains the architecture of the Jenkins -

1. A developer commits the code, to the source code repository and at the same time Jenkins server checks the repository for the changes.

2. Soon after a commit is made, the Jenkins server detects the changes that have occurred in the source code repository, pulls those changes and starts preparing a new build.

3. If the build fails, then the concerned team is notified.

4. If a build is successful, then Jenkins deploys the built-in test server.

5. It will continue to check the source code repository for changes made in the source code and the whole process keeps on repeating.

Distributed Architecture of Jenkins

Jenkins works on master-slave architecture, where a master and a slave communicate with each other through TCP/IP protocol and the master acts as the main server of Jenkins whereas a slave is a java executable running on a remote machine.

Jenkins Installation Process

Jenkins can be installed on both windows and mac but for this, there are some hardware and software requirements which should be followed :

Hardware Requirements :

At least 256 MB of RAM in the system and 1 GB space in the hard drive.

Software Requirements :

Latest version of Java Development Kit(JDK) or JAVA Runtime Environment(JRE).

Download Jenkins-

The following steps should be followed for downloading the Jenkins :

  1. Go to https://jenkins.io/download/.
  2. Here two options are available for the download-

a. Long Term Support Release(LTS) :

Long-term support releases are available every 12 weeks. They are stable and are widely tested. This release is intended for end-users.

b.Weekly Release:

Weekly releases are made available every week by fixing bugs in their earlier versions. These releases are intended towards plugin developers.

3. Select the Generic Java Package(.war) from the LTS option for downloading it.

4. After (.war) file is downloaded place it into any location on your system.

(I have kept it into Downloads).

5. Open terminal (mac) or command prompt (windows), then go to the directory where your Jenkins.war file is situated and type the command given below -

java -jar Jenkins*.war

7. Jenkin's installation process will get started.

8. After the installation is completed go to (http://localhost:8080), if you are able to access the above url it confirms that Jenkins is successfully installed on your system.

9. The URL (http://localhost:8080) opens the following window, where we need to unlock the Jenkins by giving the password.

10. The password can be retrieved from the terminal after the installation gets completed.

For example like this-

But if in case you are unable to find your password on Mac-Os then here’s the solution for it-

a. On your mac go to — /Users/Shared/Jenkins/Home.

b. Right-click on the secrets/ folder and select Get Info.

c. On clicking Get Info following window will appear.

d. Then click on the lock image present on the above window >enter your password > ok

e. Click on the “+” at the left -bottom corner of the pop-up window and add the user, Click Settings icon from the pop-up window and Apply changes.

f. Open the secrets folder find the initial admin password file get the password from there.

g. Paste the password by opening this URL-https://localhost:8080/login?from=%2F and click on Continue Button.

11. Customization of Jenkins is the next step click on the “Install suggested plugins button” so Jenkins will retrieve and install the essential plugins

12. After all the plugins are installed, Create the first user window will appear to fill the username, password > save and continue.

13. Then a window for starting the Jenkins will appear.

14. Next step will be for creating new jobs/projects in Jenkins, click on the create new jobs button.

After the set-up is done the next step is plugin management, we need to set-up the basic plugins in Jenkins for proper functioning.

1. Git Plugin — for the set -up of git plugin follow these steps:

1. Click on Manage Jenkins option present on the left-hand side of the Jenkins window.

2. Click on Manage Jenkins option > Click on Available option > Search for the git plugin Option > Click on install without restart > Once the installation is completed restart the Jenkins.

3. After the restart git will be available for configuring jobs, for the verification of the same — Click on the New Item > Enter the item name > Select freestyle project > Click OK.

4. In the next screen, git will be available as an option.

Note — In some cases, git plugin is already present in Jenkins, so check this from the installed option present in the manage Jenkins section.

2. Maven Plugin — For the set-up of maven follow the steps below:

1. Go to the official site of maven(Apache Maven) > Click on binary.zip file from the Files section.

2. Go to Jenkins > Click on Manage Jenkins > Click on Configure System > Click on Add Maven Button from the Maven section > Uncheck Install automatically option > Add any name and location of Maven home > Click on Save.

3.Performance Plugin — If you want to run Jmeter projects in Jenkins then performance plugin is required. For its set-up follow the steps given below:

Click on Manage Jenkins > Click on Manage Plugins > Click on Available option > Search for performance plugin > Click on install without restart > Once the installation is completed restart the Jenkins.

4. Github Webhook Integration — We need to do this so that, every time a developer commits code to git hub our build will be triggered. Webhook is an Http callback an Http post that occurs when something happens through a simple event-notification via Http post.

The following are the steps for its set-up

1. Go to the settings page of the git repository.

2. Click on Webhook and then click on add repository.

3. Write the payload URL (it is the URL that is received from the webhook post request).

For example — http://localhost:4567/payload.

4. Set the content type as application/JSON.

5. Enable the SSL verification so that webhook payloads are delivered to the URL endpoint securely.

6. Set the event trigger method from the options provided.

For example -Send me everything ( If there is any push or pull in our repository we will be notified).

7. After these processes are completed using this webhook in Jenkins for this follow these steps:

  1. Go to Manage Jenkins -> Configure System.
  2. Add your repository link in the git hub pull requests section and click on Save.
  3. Now go to the Jenkins pipeline and select “GitHub hook trigger for GITScm polling.”

Jenkins has been proved as a very beneficial product since it has made the development cycle of the project very fast, new features are more readily available to the users. Now with the help of Jenkins the code is built and tested as soon as the developer commits the code. This feature has made Jenkins more powerful and useful than others.

--

--