How to Setup Jenkins and create a simple Jenkins Job.
By: Shravani Radhakrishna
Tags: Jenkins, Continuous Deployment, Continuous Integration, Continous Delivery, Jenkins Pipeline

Jenkins

Jenkins is a powerful tool used to build our application code in automatic manner.In simple manner it will allow us to project CI/CD.At starting i was not aware of What does CI/CD means now I’m pretty clear with that terms.

Continuous Integration : Continuous integration (CI) is a practice where a team of developers integrate their code early and often to the main branch or code repository. The goal is to reduce the risk of seeing “integration hell” by waiting for the end of a project or a sprint to merge the work of all developers.

Continuous Deployment: Continuous Deployment (CD) is a software release process that uses automated testing to validate if changes to a codebase are correct and stable for immediate autonomous deployment to a production environment.

Advantages and Disadvantages of Jenkins

There are several tools available in market like TeamCity,Bamboo,Hudson,Buildbot,Travis CI, etc..Then Why Jenkins are popular

Open source. Build on top of java. Improved version of Hudson. Provides delivery Environment for any language. Simplified Administration environment. Security provided by role based authorisation. Role based access control(RBAC). Highly scalable and Availability. Container supports various frameworks like Docker. There are more Plugins which makes our tasks easy.

Jenkins Architecture

Master Slave Architecture

A single Jenkins server cannot handle multiple files and builds simultaneously for that, a distributed Jenkins architecture is necessary.

As you can see in the diagram provided below, on the left is the Remote source code repository. The Jenkins server accesses the master environment and the master environment can push down to multiple other Jenkins Slave environments to distribute the workload.

That lets you run multiple builds, tests, and product environments across the entire architecture. Jenkins Slaves can be running different build versions of the code for different operating systems and the server Master controls how each of the builds operates.

Master and slave Architecture

Prerequisites

A machine with: 256 MB of RAM, although more than 2 GB is recommended and 10 GB of drive space (for Jenkins).

Java 8 or 11 (either a JRE or Java Development Kit (JDK) is fine).

Installations and setup

Jenkins for Windows Java 8 JRE/JDK Git Before Jenkins download need to install Java. After installation set the JDK path in Environment variables(ex: c:/Program Files/java/jdk1.8.0_168). Add JDK bin path in Path variable in environment variable.(ex: c:/Program Files/java/jdk1.8.0_168/bin). Open cmd promt type java -version check the version. Javac -version. Download Jenkins.(https://www.jenkins.io/download ) Download Generic Java War file or Windows depends upon the OS you use. After download Click on .msi file and proceed with installation steps. Once installation is done Browse to http://localhost:8080.By default jenkins runs on port 8080. Copy the administrative password from specified path CL/Program Files(x86)/Jenkins/secrets/initialAdminPassword.

fig1

13. Customise Jenkins Install suggested Plugins which are suggested and most used or select plugins that most need for you.

fig2

14. Now I’m selecting Install suggested plugins because some plugins might have dependencies.

fig3

15. Create the first admin user.

fig4

16. Login to the Jenkins.

17. You will find a dashboard

fig5

Configuration setup for SMTP mail server:

18. In dashboard on left side click on Manage Jenkins.

19. Click on configure system

fig6

20. Go to the bottom and you will find Email notifications.

21. Enter the mail information as shown in the below screenshot.

22. In the screenshot email is personal gmail you can configure the organisation details and save.

Additional s/w setup:

In case we are working with java source code we need to make sure JDK,git,Maven etc are installed.

→ Click on Manage Jenkins.

→ click on global tool configuration.

→ click on Add JDK if it is installed the path otherwise install it.

→ In the same way check for GIT and other required tools.

→ Save changes.

If we don’t set up these tools Jenkins will not be able to build the task.

For example (C:\Users\sravani.manduva\AppData\Local\Programs\Git\cmd\git.exe) path of git.