How to Setup Jenkins and create a simple Jenkins Job.

Shravani Radhakrishna
5 min readJul 6, 2021

--

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

  1. Open source.
  2. Build on top of java.
  3. Improved version of Hudson.
  4. Provides delivery Environment for any language.
  5. Simplified Administration environment.
  6. Security provided by role based authorisation. Role based access control(RBAC).
  7. Highly scalable and Availability.
  8. Container supports various frameworks like Docker.
  9. 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

  1. Jenkins for Windows
  2. Java 8 JRE/JDK
  3. Git
  4. Before Jenkins download need to install Java.
  5. After installation set the JDK path in Environment variables(ex: c:/Program Files/java/jdk1.8.0_168).
  6. Add JDK bin path in Path variable in environment variable.(ex: c:/Program Files/java/jdk1.8.0_168/bin).
  7. Open cmd promt type java -version check the version.
  8. Javac -version.
  9. Download Jenkins.(https://www.jenkins.io/download ) Download Generic Java War file or Windows depends upon the OS you use.
  10. After download Click on .msi file and proceed with installation steps.
  11. Once installation is done Browse to http://localhost:8080.By default jenkins runs on port 8080.
  12. 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.

Jenkin Jobs:

We have different type of jobs available

  1. Freestyle
  2. Pipeline
  3. Maven
  4. External jobs
  5. Multiconfiguration job

Job Execution:

  • Jobs start its execution when it is triggered or invoked.
  • First it complete the prebuild jobs.
  • Later completes the main job and executes post build steps.
  • Sequential execution steps are known as job changing (pipeline).

How to create a simple job?

  1. On left side of Main Dashboard you will find New Item
  2. Enter the Job name.Here I’m selecting the Freestyle Project and clicking ok.

3. There are a lot of tabs available in this session such as SCM, build triggers,post build actions,Build env etc.

4. This is a simple job not adding more configuration just creating by adding description.

5. Click on build environment tab and If you want to run windows commands select windows batch command and echo something or enter command dir and save it.

6. On the left side you will find the Build now option click on that.

7. At bottom you will find the Build history click on that.(If dot is in blue color means build is success)

8. On left side you will see console output click on that we see the build output.

9. A simple job creation and build done this is not automatically triggered.

This is very Easy right will post more articles about different technologies keep me posted in the comments section and give a clap.

--

--

Shravani Radhakrishna
Shravani Radhakrishna

No responses yet