Global Tool Configurations

In linux servers, we can install only one version of the tool at a time eg: we can install only maven 3.6 version and we cannot have both maven 3.6 and 3.7 version in same server.

By configuring Global Tool configuration, we can have multiple version of maven, nodejs, gradle, java and ant

How to configure multiple versions of maven

From Jenkins dashboard, click on Manage Jenkins Jenkins

Click on Global Tool Configurations

Jenkins

Click on Maven installations.. Jenkins

Scroll down and click on Add Maven and give unique name in Name feild and select the maven version 3.6.3 from the dropdown Jenkins

Now click on Add Maven once again Jenkins

Add the name and select the version 3.8.1 and click on save Jenkins

How to this maven in Jenkinsfile
tools {
    maven 'maven-3.6.3'
}

maven-3.6.3 is the unique name which we have given in the global tool configurations.

When we use maven for first time by referring to this name and run the job, jenkins will automatically download the maven tar file, extract and save it in /var/lib/jenkins/tools/ folder

From the next build it will use the maven from that folder, it won’t download everytime

Jenkins

Jenkins

How to configure multiple versions of nodejs

In Global Tool Configuration scroll down click on NodeJS installations..

Jenkins

Click on Add NodeJs add the name and selcet the version 10.0.0(As per your requirements) Jenkins

Now click on Add NodeJs once again, give the name and select the required version and click on save Jenkins

How to use nodejs in Jenkinsfile
tools {
    nodejs "nodejs-10.0.0"
}

nodejs-10.0.0 is the unique name which we have given in the global tool configurations.

When we use nodejs for first time by referring to this name and run the job, jenkins will automatically download the mnodejs tar file, extract and save it in /var/lib/jenkins/tools/ folder

From the next build it will use the nodejs from that folder, it won’t download everytime

Jenkins

Jenkins