© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
P. P. DingareCI/CD Pipeline Using Jenkins Unleashedhttps://doi.org/10.1007/978-1-4842-7508-5_5

5. Managing Plugins in Jenkins

Pranoday Dingare1  
(1)
Pune, Maharashtra, India
 

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

The following list includes some commonly used Jenkins plugins along with the tools they integrate into:
  • Git:

The Git plugin is used to integrate with the Git version controlling system.

Git is a distributed version controlling system that allows developers to work collaboratively with software application code. We talk about Git in more detail in Chapters 10 and 12.
  • 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.

We cover Maven in more detail in upcoming chapters.
  • 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.

Use the following steps to go to the Manage Plugins page and begin installing the required plugins.
  1. 1.

    Log into Jenkins. Once you are logged in, you will see the Jenkins dashboard.

     
  2. 2.

    Go to the Manage Jenkins page. Click the Manage Jenkins link available on the Jenkins dashboard to open the Manage Jenkins page.

     
  3. 3.

    Go to the Manage Plugins page.

     
  4. 4.

    Click the Manage Plugins link. Clicking this link will open the Plugin Manager page, as shown in Figure 5-1.

     

An image of the user interface of Jenkins Plugin Manager. The link in the address bar reads localhost colon 8080 slash plugin Manager slash. A filter box is above. A tabular column lists updates, chosen, available, installed, and advanced. Under updates, the column headers are install, name, version, released, and installed.

Figure 5-1

The Jenkins Plugin Manager

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

This tab lists the installed plugins when updated versions of them are available to download and install. You can install updated versions of plugins by checking the checkboxes of desired plugin updates and clicking the Download Now and Install After Restart button, as shown in Figure 5-2.

Plugin Manager configuration page has tabs, Updates, Available, Installed, and Advanced. A tabular-like format is presented under the opened Updates tab. It has 1 row and 4 columns. The column headers are Install, Name with a downward arrow, Version, and Installed. The row has the marked Blue Ocean beta plugin entry. Download now and install after restart button is below. Check now button is at the right.

Figure 5-2

Plugin entry to be updated

The Available Tab

This tab shows a list of Jenkins plugins available to download and install.

To install a new plugin, go to the Available tab and type the name of the plugin in the Search field. For example, if you want to install the JUnit plugin then you would enter Junit into the search field. You will see the JUnit plugin entry at the top of the plugins list. Then you simply check the Junit plugin entry’s checkbox. See Figure 5-3.

The Jenkins Plugin Manager exhibiting the checked J Unit plugin entry under the Available tab. The mentioned plugin entry appears in the list as one of the search results of the search query J Unit. Its functions to Build Reports and to allow J Unit-format test results to be published are observed. Install without restart and Download now and install after restart button is below. Check now button is on the right.

Figure 5-3

The Junit plugin entry is selected to start the installation

After checking the checkbox, you can click either the Install Without Restart or the Download Now and Install After Restart button.
  • 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.

You have to ask for details of the proxy server from your IT department and then configure those details in the HTTP Proxy Configuration section (see Figure 5-4).

An image of the Jenkins Plugin Manager exhibiting the H T T P Proxy Configuration section under the Advanced tab. The Server, Port, User Name, Password, and No Proxy Host sub-sections have input boxes underneath. Each, except for Password, has a circle with a question mark symbol on the right side. The Submit and Advanced buttons are observed below.

Figure 5-4

HTTP Proxy Configuration page

Let’s look at the different fields from this section one by one:
  • 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.

The Update Center only allows you to install the latest released version of a plugin. If you need a specific version of the plugin, you can download the .HPI archive of the plugin and install it manually by using the Upload Plugin section. Follow these steps:
  1. 1.

    Download the .HPI file of the required plugin version.

     
  2. 2.

    Browse the downloaded .HPI file by clicking the Choose File button.

     
  3. 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-

Error: While installing Jenkins plugins, it fails with the following SHA -1 error:
java.io.IOException: Downloaded file /var/lib/jenkins/plugins/*.tmp does not  match expected SHA-1, expected 'f2ncNlydUUSPrk6SoG255v+2kQU=', actual 'lZRJco4Ouv1j0AG4Aet7HadHg/Q='

Reason: The Jenkins Update Center is not synced with Jenkins. You are running Jenkins on a machine which operates behind the proxy.

Solution for “Jenkins Update Center is not synced with Jenkins”:
  1. 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. 2.

    Restart the Jenkins server and try to install the plugin again.

     
Solution for “You are running Jenkins on a machine which operates behind the proxy”:
  1. 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.

     
If the proxy machine does not have authentication set, leave the username and password fields blank.
  1. 2.

    Click the Advanced button, enter the Jenkins Update Center’s URL in the Test URL field, and then click the Validate Proxy button.

     
  2. 3.

    After a successful proxy validation, click the Submit button.

     
  3. 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.

Solution 1: Change the Update Center URL to use http:// instead of https://:
  1. 1.

    Choose Manage Jenkins ➤Manage Plugins.

     
  2. 2.

    Go to the Advanced tab.

     
  3. 3.

    Scroll down the page to the end, where you will see the Update Site section.

     
  4. 4.
     
  5. 5.

    Try to install the plugin again.

     
Solution 2: Update Java to the latest version:
  1. 1.

    Download and install the latest Java version available.

     
  2. 2.

    Add a path to the bin folder from the latest installed Java in the PATH environment variable.

     
  3. 3.

    Save this environment change and restart the Jenkins server.

     
  4. 4.

    Try to install the plugin again.

     
Note

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.

Solution 3: Start the Jenkins server using the .WAR file from the libsecurity folder in the latest Java installation folder.
  1. 1.

    Install the latest version of Java.

     
  2. 2.

    Start the command prompt and change the working directory to the Java Installation dirlibsecurity folder.

     
If you have the latest JDK 15 installed on your machine at D:JDK15jdk-15.0.2, open the command prompt and change the working directory to D:JDK15jdk-15.0.2libsecurity.
  1. 3.

    Run the Jenkins.war file from D:JDK15jdk-15.0.2libsecurity.

     
  2. 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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.21.115