0
0
Jenkinsdevops~5 mins

Tool auto-installation in Jenkins - Commands & Configuration

Choose your learning style9 modes available
Introduction
Sometimes Jenkins needs tools like Git or Maven to run jobs. Tool auto-installation lets Jenkins download and set up these tools automatically, so you don't have to install them manually on the server.
When you want Jenkins to prepare required tools automatically for your build jobs.
When you have multiple Jenkins agents and want consistent tool versions on all of them.
When you want to avoid manual installation errors or version mismatches.
When setting up a new Jenkins server quickly without installing tools by hand.
When you want to keep tools updated easily through Jenkins configuration.
Config File - config.xml
config.xml
<?xml version="1.0" encoding="UTF-8"?>
<hudson.plugins.git.GitTool>
  <name>Default Git</name>
  <home></home>
  <properties>
    <hudson.tools.InstallSourceProperty>
      <installers>
        <hudson.plugins.git.installations.GitInstaller>
          <id>git-installer</id>
          <label>Install from official site</label>
          <url>https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.40.1.tar.gz</url>
          <version>2.40.1</version>
        </hudson.plugins.git.installations.GitInstaller>
      </installers>
    </hudson.tools.InstallSourceProperty>
  </properties>
</hudson.plugins.git.GitTool>

This config.xml snippet defines a Git tool in Jenkins with auto-installation enabled.

  • name: The tool name Jenkins uses.
  • installers: Defines how Jenkins downloads and installs the tool.
  • url: The download link for the Git version to install.
  • version: The version number Jenkins tracks.

When a job needs Git, Jenkins will download and install this version automatically if not present.

Commands
Starts the Jenkins server so you can access the web interface to configure tool auto-installation.
Terminal
java -jar jenkins.war
Expected OutputExpected
Running from: /home/user/jenkins.war INFO: Jenkins is fully up and running INFO: Jenkins initial setup is required. An admin user has been created and a password generated.
Uploads the tool configuration XML to Jenkins to set up Git auto-installation.
Terminal
curl -X POST http://localhost:8080/configureTools -d @config.xml -H "Content-Type: application/xml"
Expected OutputExpected
Configuration updated successfully
-X POST - Send data to update Jenkins configuration
-H "Content-Type: application/xml" - Tell Jenkins the data format is XML
Uses Jenkins CLI to trigger installation of the Git tool named 'Default Git' defined in the config.
Terminal
java -jar jenkins-cli.jar -s http://localhost:8080/ install-tool git "Default Git"
Expected OutputExpected
Installing Git version 2.40.1... Installation complete.
-s http://localhost:8080/ - Specify Jenkins server URL
Lists all tools configured in Jenkins to verify that Git tool is installed and ready.
Terminal
java -jar jenkins-cli.jar -s http://localhost:8080/ list-tools
Expected OutputExpected
Tool: Default Git, Version: 2.40.1, Status: Installed
-s http://localhost:8080/ - Specify Jenkins server URL
Key Concept

If you remember nothing else from this pattern, remember: Jenkins can download and install required tools automatically to keep your build environment consistent and easy to manage.

Common Mistakes
Not enabling the auto-installation option in Jenkins tool configuration.
Jenkins will not download or install the tool automatically, causing build failures.
Always check the auto-installation box and provide a valid download URL and version.
Using an incorrect or unreachable URL for the tool installer.
Jenkins cannot download the tool, so installation fails silently or with errors.
Use official and accessible URLs for tool downloads and test them before configuring.
Not restarting Jenkins or reloading configuration after updating tool settings.
Changes may not take effect, so Jenkins uses old settings or no tools.
Restart Jenkins or reload configuration after changing tool auto-installation settings.
Summary
Start Jenkins server to access the web interface or CLI.
Configure tool auto-installation by uploading a valid XML config with tool details.
Trigger tool installation using Jenkins CLI to ensure the tool is ready.
Verify installed tools with Jenkins CLI to confirm setup success.