Issue
It is normal to have various types of agents with different OS (linux, windows, …) and most of the time we will need to install some tools on them required by the build process.
Below are different approaches to manage and maintain the necessary tools in a simple way regardless of the type of agent.
Environment
-
CloudBees CI (CloudBees Core) on modern cloud platforms - Managed controller
-
CloudBees CI (CloudBees Core) on modern cloud platforms - Operations Center
-
CloudBees CI (CloudBees Core) on traditional platforms - Client controller
-
CloudBees CI (CloudBees Core) on traditional platforms - Operations Center
Resolution
As example, we are going to use the Maven tool installation to show the different alternatives. These methods should work in the same way with other Tool installation
In Jenkins, it’s possible to create a Tool and add different installers. Depending on the installer selected, Jenkins will act differently.
Updating your container image to have the tools pre-installed
If you are using ephemeral build agents, for example Kubernetes agents, a best practice would be to either use a container that already has the tools you need installed (eg maven), or create a Dockerfile
using a base image you need, and install the tools during that Docker build, push that image to your preferred container registry, and reference that container image in your pod template.
Installing directly from Apache
If your nodes are able to connect to Apache and download the required tool, then you just need to use the Install from Apache
installer
And Jenkins will automatically init the download and install the Maven tool in the agent, no matter the type of agent.
have in mind that Apache installer only will be available for Apache tools. Other tools may not have this kind of installer |
Installing with custom installers
Sometimes the previous solution is not enough because of different reasons:
-
There is not connectivity between agents and Apache downloads
-
The tools requires some customization
In both cases, you will need to prepare a bundle of the tool and store it in an internal repository accessible. In this case, you can use the Extract .zip/.tar.gz
installer
or if you need some extra customization, use the Run Batch Command/Run Shell Command
installer.
If both cases you can use the label
field to filter in which agent each installer can be used.
Important The labels in the agent and installer have to match. That means that the windows
installer will be used in agents which contains the label windows
, otherwise you can expect errors installing the tool.