When working with Jenkins, you may need to use different tools/technologies like Java, Maven, etc. This chapter explains how to configure JDK and Maven from the Global Tool Configuration page.
Global Tool Configuration Settings
- 1.
First, log in to Jenkins. Once you are logged in, you will see the Jenkins dashboard.
- 2.
Click the Manage Jenkins link available on the Jenkins dashboard to open the Manage Jenkins page.
- 3.
Go to the Global Tool Configuration page by clicking the Global Tool Configuration link highlighted in Figure 6-1.
If you have plugins related to other third-party tools such as Gradle or Git installed in Jenkins, you will see settings related to these tools on this page.
Understanding the Global Tool Configuration Settings
The Maven install (called the global settings): The default location of this file is ${maven.home}conf and the file is called settings.xml file. maven.home refers to the Maven installation directory.
A user’s install (called the user settings): The default location of this file is {user.home}/.m2 and this file is also called settings.xml. The {user.home} part refers to the current user directory. We cover Maven in detail in Chapter 11.
These files contain settings required to execute Maven in order to build different Java projects. If different users working on the same machine want to keep their specific Maven settings, they keep these settings in the user settings file, whereas all common Maven settings that will be shared by all user profiles go in the global settings file.
You don’t have to have the Maven settings.xml in the user’s install, i.e., ${user.home}/.m2/settings.xml. If this file is not present, the required settings are taken from the Maven install’s settings.xml file. If the same setting is present in both settings.xml files, the setting in the ${user.home}/.m2/settings.xml gets preference.
Maven Configuration
The second part that you need to understand related to Maven is its installation. Let’s look at how you configure the Maven installations.
Click the Save button to save the configuration.
If the machine running the Jenkins job does not have Maven installed and you want Jenkins to install it automatically while running a job, you have to check the Install Automatically checkbox and configure the installer. Jenkins will do this only the first time it runs a job on a machine where Maven isn’t installed.
Let’s see how to configure a Maven installation whereby a Maven .ZIP/.TAR file is extracted.
In the Subdirectory of Extracted Archive field, provide the name of the directory that will contain the Maven installation after unzipping the folder.
As shown in Figure 6-9, the Maven tool is inside a directory named apache-maven-3.8.1. So apache-maven-3.8.1 should be the value in the Subdirectory of Extracted Archive field. That way, Jenkins will consider this directory the Maven installation location and can access Maven using the mvn command present in the bin folder.
Click the Save button on the page to save the configuration.
Java Configuration
Click the Add JDK button
If you do not have JDK installed and want Jenkins to install it on demand, then check the Installed Automatically checkbox and configure the installer as explained in the previous Maven configuration section.
Summary
This chapter explained how to set up important tools like Maven and JDK. If any Jenkins job needs these tools and job execution machine does not have them, those jobs will fail. Jenkins installs these tools using configured installers, which is considered a very important feature of Jenkins. The next chapter talks about how to manage security in Jenkins using its different security related features to implement authentication and authorization in Jenkins.