jenkinsci / custom-tools-plugin

A generic tool installer for Jenkins
https://plugins.jenkins.io/custom-tools-plugin
Other
25 stars 36 forks source link
adopt-this-plugin jenkins jenkins-plugin tools

Custom Tools Plugin for Jenkins

Jenkins Plugin GitHub release Jenkins Plugin Installs

A generic tool installer. You define how tools get installed, and the plugin will automatically install them when needed.

Overview

A job will often require a tool not already installed on your Jenkins agents. In large environments, this often results in waiting on an administrator. The goal of this plugin is to let users manage their own tools, without requiring this administrator involvement.

Using this plugin, you can define a script (or just a URL) for installing a tool using standard Jenkins Tool Installers. Plugins like Extra Tool Installers can be also used in this plugin. You then define which jobs require the tool, and the plugin installs them as needed before the build runs.

Changelog

Usage

Defining tools

Let's say that you have a build that needs NodeJS. It is possible to use a NodeJS Plugin for it, but we will use it as an example.

  1. Go to the Manage Jenkins > Global Tool Configuration page and to find the Custom Tool section there.
  2. Add a new NodeJS Tool
  3. Configure the tool installer. E.g. you can use a script as in the example below
  4. Configure Exported paths. The field lets you specify multiple directory patterns which will be added to the $PATH so that your build needn't know where the tool is actually installed

Tool Configuration

Using tools in Freestyle projects

For Freestyle projects you need to add the tool requirement to your job's Build Environment (aka "build wrappers").

Freestyle Project. Tool Build Wrapper

Then, you can just use the tool in your job, without having to know where it's installed. The plugin will install it as needed before your job runs, and make sure the $PATH is setup correctly:

Freestyle Project. Tool Installation log

Advanced use-cases

Tool versioning

Custom Tools plugin supports versioning of tools. Versions can be configured in the global configurations and then used to install specific versions of tools in Jenkins jobs.

WARNING: This feature is a subject to the breaking changes in the future. See JENKINS-32662 for more info

Configuring Tool versions

Currently the plugin uses the functionality provided by the Extended Choice Parameter plugin, but it's a subject for a change in the future. Extended Choice Parameter plugin allows to setup versions locally in the global configuration or to reference a property file with the version listing.

If a Custom Tool has versioning enabled, Custom Tools starts retrieving versions during the tool installation. Version configuration example:

Tool Version Configuration

Some tool installers support TOOL_VERSION variables (e.g. all installers from Extra Tool Installers Plugin, so you can use versions in the installer configurations.

Using Tool Versions in Installers

Tool Version parameters

Tool version parameter is available for Jenkins jobs. If it is not specified, a default version will be used.

Tool Version Parameter Definition

Defining version parameter when starting a build:

Tool Version Parameter Usage