Ultimate Jenkins tutorial for DevOps Engineers

Jenkins is an open source automated CI/CD tool where CI stands for continuous integration and CD stands for Continuous delivery. Jenkins has its own built-in Java servlet container server which is Jetty. Jenkins can also be run in different servlet containers such as Apache tomcat or glassfish.

  • Jenkins is used to perform smooth and quick deployment. It can be deployed to local machine or on premises data center or any cloud.
  • Jenkins takes your code any sort of code such as python, java or go or JS etc. and compiles it using different compiler such as MAVEN one of the most used compiler and then builds your code in war or Zip format and sometimes as a docker Image. Finally once everything is built properly it deploy as an when required . It integrates very well with lots of third party tools.

JAVA_HOME and PATH are variables to enable your operating system to find required Java programs and utilities.

JAVA_HOME: JAVA_HOME is an (OS) environment variable that can optionally be set after either the (JDK) or (JRE) is installed. The JAVA_HOME environment variable points to the file system location where the JDK or JRE was installed. This variable should be configured on all OS’s that have a Java installation, including Windows, Ubuntu, Linux, Mac, and Android. 

The JAVA_HOME environment variable is not actually used by the locally installed Java runtime. Instead, other programs installed on a desktop computer that requires a Java runtime will query the OS for the JAVA_HOME variable to find out where the runtime is installed. After the location of the JDK or JRE installation is found, those programs can initiate Java-based processes, start Java virtual machines and use command-line utilities such as the Java archive utility or the Java compiler, both of which are packaged inside the Java installation’s \bin directory.

  • JAVA_HOME if you installed the JDK (Java Development Kit)
    or
  • JRE_HOME if you installed the JRE (Java Runtime Environment) 

PATH: Set the PATH environment variable if you want to be able to conveniently run the executables (javac.exejava.exejavadoc.exe, and so on) from any directory without having to type the full path of the command. If you do not set the PATH variable, you need to specify the full path to the executable every time you run it, such as:

C:\Java\jdk1.8.0\bin\javac Myprogram.java
# The following is an example of a PATH environment variable:

C:\Java\jdk1.7.0\bin;C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem

Installing Jenkins using msi installer on Windows Machine

MSI is an installer file that installs your program on the executing system. Setup.exe is an application (executable file) that has MSI file(s) as one of the resources. The MSI is the file extension of MSI files. They are Windows installers. An MSI file is a compressed package of installer files. It consists of all the information pertaining to adding, modifying, storing, or removing the respective software.  MSI file includes data, instructions, processes, and add-ons that are necessary for the application to work normally.

EXE is short for Executable. This is any kind of binary file that can be executed. All windows programs are exe files. Prior to MSI files, all installers were EXE files. The exe is a file extension of an executable file. An executable file executes a set of instructions or a code when opening it. An executable file is compiled from source code to binary code. It can be directly executed by the Windows OS. These files are understandable by the machine, and they can be directly executed by the operating system

MSI is a file extension of windows installer which is a software component of Microsoft Windows used for the installation, maintenance, and removal of software. Whereas, exe is a file extension of an executable file that performs indicated tasks according to the encoded instructions. 

  1. Navigate to https://www.jenkins.io/download/ and select windows option and your download of Jenkins msi will begin.
  1. Once downloaded click on the jenkins.msi
  1. Continue the Jenkins setup.
  1. Select the Port 8080 and click on Test Port and then Hit Next.
  1. Provide the admin password from the provided Path mentioned in RED color.
  1. Further install the plugins required for jenkins.
  1. Next,it will prompt for First admin user. Please fill the required information and keep it safe with you , as you will use this to login.
  1. Now Jenkins URL configuration screen will appear , keep it as it is for now.
  1. Click on Save and Finish.
  1. Now your Jenkins is ready , click on Start using Jenkins. Soon, you will see Jenkins Dashboard. You can create New Jobs by clicking on New Item.

Installing Jenkins using jenkins exe on Windows Machine

  1. Similarly now install jenkins.war from jenkins URL and click on Generic Java package(.war).
  2. Next run the command as below.
java -jar jenkins.war -http=8181
  1. Next, copy the Jenkins password from the log output and paste it in the as you did earlier in windows msi section point (5) and follow rest of the points.

Installing jenkins on Apache Tomcat server on Windows Machine

  1. Install the Apache Tomcat on windows machine from https://tomcat.apache.org/download-90.cgi and click on tomcat installer as per your system. This tutorial is performed on 64 bit windows machine.
  1. Next, unzip the tomcat installation folder and copy the jenkin.war file in the webapps folder.
  1. Next, go inside the bin folder and run the tomcat by clicking on the startup batch script.
  1. Finally you will notice that Apache Tomcat has started and Jenkins as well.
  1. Now, navigate to localhost:8080 URL and you should see tomcat page as shown below.
  1. Further, navigate to localhost:8080/jenkins to redirect to Jenkins Page.

Configuring the Jenkins UI

  1. First click on Manage Jenkins and then navigate to Configure system.
  1. Next, add the system message and save it which should display this message on Jenkins everytime as below.
  1. To configure the name of the Jobs add the name Pattern as below.
  1. Next, try creating a a new Jenkins Job with random name then it will not allow you and display the error message.

Managing User’s and Permission’s in Jenkins UI

  • Go to Manage Jenkins and Navigate to Manage users in the Jenkins UI.
  • Then Create three users as shown below admin, dev, qa.
  • Next, Navigate to Manage Jenkins and choose Configure Global Security.
  • Next select Project-based Matrix Authorization Strategy and define the permissions for all users as you want.

Role Based Stratergy

  • In Previous section you noticed that adding all users and grnating all permissions is little tough job. So, instead create a role and add users in it. To do that first step is to install the Plugin as shown below.
  • Next select Role based Stratergy as shown below and define the permissions for all users as you want.
  • Next, navigate to Manage Jenkins and then to Manage and Assign Jenkins and then click on Manage Roles.
  • Add 3 Global Roles named DEV Team, QA Team and admin.
  • Add 2 Items Roles developers and Testers with define patterns so that Jobs names are declared accordingly.
  • Next, Click on Assign Role
  • Assigning the roles as shown below.

Conclusion

In this tutorial you learnt how to install jenkins on windows through various ways , how to configure Jenkins Dashboard UI and how to manager users and Permissions.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s