The software build lifecycle usually includes phases like pulling the source code from a source code management tool, compiling the source code, unit and integration testing, and then building the library and releasing it. To perform those phases, you need to use different categories of tools, including source code management (SCM) tools, unit/integration testing tools, build tools, etc. Jenkins needs to interface with those tools as part of executing the end-end build lifecycle. Jenkins uses plugins to interface with these tools.
This chapter explains what a plugin is, covers the plugins commonly used with Jenkins, and explains how to install plugins using the Jenkins Plugin Manager. During the installation process, you may face issues, so the last section of this chapter discusses how to resolve some of these common issues.
What Are Plugins
A plugin is a software component that adds a specific feature to an existing computer program. There are various plugins developed by the Jenkins team to customize the usage of Jenkins.
Commonly Used Jenkins Plugins
Git:
The Git plugin is used to integrate with the Git version controlling system.
Maven Integration:
The Maven Integration plugin integrates with the Maven build tool. Maven is a build tool that helps you automate important build phases like compilation, packaging, testing, etc.
Email Extension:
In Jenkins you can configure email notifications that will notify the team about the status of the current build. Using the Email Extension plugin, you can customize the email notifications and add more details to the email sent as an notification. You’ll see this in action in upcoming chapters.
Installing the Plugins in Jenkins
Now that you know what a plugin is and know how they are going to help you, this section explains the process of installing plugins in Jenkins.
- 1.
Log into Jenkins. Once you are logged in, you will see the Jenkins dashboard.
- 2.
Go to the Manage Jenkins page. Click the Manage Jenkins link available on the Jenkins dashboard to open the Manage Jenkins page.
- 3.
Go to the Manage Plugins page.
- 4.
Click the Manage Plugins link. Clicking this link will open the Plugin Manager page, as shown in Figure 5-1.
Understanding the Plugin Manager
The Plugin Manager page updates and installs the different Jenkins plugins. There are four tabs on the Plugin Manager configuration page. They are Updates, Available, Installed, and Advanced. We are going to look at each one.
The Updates Tab
The Available Tab
This tab shows a list of Jenkins plugins available to download and install.
If you click the Install Without Restart button, the plugin download will start. Once it’s downloaded, the plugin will be installed immediately.
You have to wait until the JUnit plugin installation status is shown as Success in green. It will first download the plugin and then immediately install it.
This may take a while depending on the speed of your Internet connection. Once you see Success as the JUnit plugin installation status, the plugin is ready to be used.
If you click the Download Now and Install After Restart button, the plugin will be downloaded but not installed. The plugin will be installed after you restart the Jenkins server.
The Installed Tab
This tab shows the list of all installed Jenkins plugins in your Jenkins server along with each plugin’s installed version.
To uninstall an existing plugin, from the Installed tab, search for the plugin to be uninstalled by typing its name in the Search field. Check the checkbox available for the plugin and then click the Uninstall button.
Plugins can also be uninstalled by removing the corresponding .HPI file from the JENKINS_HOME/plugins directory.
Disabling a plugin is a way to retire a plugin. Jenkins will consider the plugin as installed, but it will not start it and any extensions contributed by plugin will not be visible.
To disable a plugin, uncheck the checkbox on the Installed tab of Manage Jenkins page.
The Advanced Tab
Internet access typically goes through and is controlled by proxy servers. Machines cannot make any direct Internet requests when a proxy server is configured. Internet requests should go to the proxy server and then reach the Internet.
If your organization has such proxy server, Jenkins cannot access the Internet while running any job. For example, accessing gitlab.com to pull the source code will not be allowed to the Jenkins instance. You will learn about Jenkins jobs in upcoming chapters. Jenkins cannot access the Update Center to download Jenkins plugins either. You need to configure proxy settings in Jenkins in order to work with Jenkins running behind the proxy.
Server: Enter the IP address of your proxy server in the Server field.
Port: Enter the port of the proxy server machine.
Username: If the proxy’s server has authentication set, enter the username of those credentials in the Username field. If authentication is not set, keep this field blank.
Password: If the proxy’s server has authentication set, enter the password of those credentials in the Password field. If authentication is not set, keep this field blank.
No Proxy Host: Specify the IP address or hostname patterns that should not go through the proxy. This setting is used to mention servers that can be accessed directly (without going through a proxy server).
After specifying all the required details, click the Submit button.
- 1.
Download the .HPI file of the required plugin version.
- 2.
Browse the downloaded .HPI file by clicking the Choose File button.
- 3.
Click the Upload button.
Jenkins plugins are downloaded from the Update Center URL, which is shown in the URL section.
Troubleshooting Installation Problems
There are some common problems encountered during the Jenkins plugin installation. This section discusses such common problems encountered, their reasons, and their solutions.
Problem 1
Jenkins Plugin Installation Failed: Downloaded file /var/lib/jenkins/plugins/ does not match expected SHA-
Reason: The Jenkins Update Center is not synced with Jenkins. You are running Jenkins on a machine which operates behind the proxy.
- 1.
Choose Manage Jenkins ➤ Manage Plugins and click the Advanced tab. Scroll down the page to find the Update Site section. Click the Check Now button. This will sync your Jenkins server with the Update Center.
- 2.
Restart the Jenkins server and try to install the plugin again.
- 1.
If you are running Jenkins on a machine that operates behind the proxy, you have to configure the proxy machine settings by choosing Manage Jenkins ➤Manage Plugins. On the Plugin Manager page, go to the Advanced tab.
- 2.
Click the Advanced button, enter the Jenkins Update Center’s URL in the Test URL field, and then click the Validate Proxy button.
- 3.
After a successful proxy validation, click the Submit button.
- 4.
Try to install the plugin again. If it fails, then restart the Jenkins server and try again.
Problem 2
javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
While installing plugins, you get this error:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Reason: The Jenkins Update Center URL in Manage Jenkins ➤ Manage Plugins is set to an HTTPS URL by default, which must be accessed with additional security measures, like security certificates for example.
JDK, which we are using to run the Jenkins server, is bundled with lots of trusted Certificate Authority (CA) certificates. These certificates are in a file called cacerts, which is present in the libsecurity folder inside the Java installation directory. This cacerts file does not have a certificate, which will trust the Jenkins Update Center website URL due to nonavailability of latest security certificates. This could be due to old version of Java being used to start the Jenkins server.
Solutions: There are various solutions to this problem.
- 1.
Choose Manage Jenkins ➤Manage Plugins.
- 2.
Go to the Advanced tab.
- 3.
Scroll down the page to the end, where you will see the Update Site section.
- 4.
Change the URL from https://updates.jenkins.io/update-center.json to http://updates.jenkins.io/update-center.json and click the Submit button.
- 5.
Try to install the plugin again.
- 1.
Download and install the latest Java version available.
- 2.
Add a path to the bin folder from the latest installed Java in the PATH environment variable.
- 3.
Save this environment change and restart the Jenkins server.
- 4.
Try to install the plugin again.
If you are updating Java to versions other than Java 1.8 or Java 1.11 then, when starting the Jenkins server using the .WAR file, you need to mention the --enable-future-java flag. For example, the command to start Jenkins.war is java –jar D:JenkinsJenkins.war --enable-future-java.
- 1.
Install the latest version of Java.
- 2.
Start the command prompt and change the working directory to the Java Installation dirlibsecurity folder.
- 3.
Run the Jenkins.war file from D:JDK15jdk-15.0.2libsecurity.
- 4.
Try to install the plugin again.
Use Solution 3 if other applications on your machine need a specific version of Java other than the latest one and hence you cannot update the PATH environment variable to point to the latest version of Java.
Note If you are using the latest version of Java to start the Jenkins server in order to resolve Problem 2, make sure you revert to the Jenkins supported Java versions (JDK 1.8 or JDK 1.11) after the plugin installation is done. If you continue using unsupported versions, you will encounter errors when running Jenkins pipeline jobs. (We cover pipeline jobs in upcoming chapters.)
Summary
This chapter discussed how the Jenkins Plugin Manager helps you install/update/uninstall different Jenkins plugins. You also learned about errors that you might come across when installing Jenkins plugins, as well as the different solutions to resolve them. The next chapter discusses how to configure some commonly used tools like Maven, Git, and Java from the Global Tools Configuration page.