Child pages
  • Tool Auto-Installation
Skip to end of metadata
Go to start of metadata

Overview

Lets you configure tools so that agents will install them on demand whenever running a job that needs them. This could be especially useful when running a large farm of agents in a cloud which all start with a minimal operating system configuration.

Several techniques are already supported: run arbitrary shell command; download & unpack archive from arbitrary URL; download and install official Oracle JDK, Ant release, or Maven release.

The configuration is part of a tool; a project owner just picks a tool (JDK, Ant, Maven, ...) by name as usual, and may observe a build running some extra steps if it needs to perform an installation, but it is otherwise transparent. Installers can be limited to agents marked with a label.

Demo Configuration

Master

Jenkins 2.7.1 on localhost:8080 with no executors.

Node config

One JNLP agent node ubuntu-vbox with one executor and Remote FS root set to /jenkins.

Tool Config
  1. JDK installations has one entry with name JDK 6 and a JDK installer set to 6u13.
  2. Ant installation has one entry with name Ant 1.7.1 and an Ant installer set to 1.7.1.
Test Project

Freestyle project, no SCM. Two build steps:

  1. Execute shell with Command:

    echo "JDK: $JAVA_HOME"
    echo '<project/>' > build.xml
    
  2. Invoke Ant with Targets set to -version.

Agent

An Ubuntu 8.10 server installation inside VirtualBox (NAT networking) with only default-jre-headless installed and user jenkins added.

/etc/rc.local
#!/bin/sh -e
su - jenkins -c /jenkins/slave-jnlp 2>&1 | perl -p -e 's/\n/\r\n/g' 1>&2 &
/etc/sudoers
# ...
jenkins ALL=NOPASSWD: ALL
/jenkins/slave-jnlp
#!/bin/sh
dir=`dirname $0`
server=http://10.0.2.2:8080
node=ubuntu-vbox
while :
do
    wget -O $dir/slave.jar $server/jnlpJars/slave.jar && \
        java -jar $dir/slave.jar -jnlpUrl $server/computer/$node/slave-agent.jnlp
    sleep 15
done

Expected project console output

...
Building remotely on ubuntu-vbox
...
JDK: /jenkins/tools/JDK_6
...
[...] $ /jenkins/tools/Ant_1.7.1/bin/ant -version
Apache Ant version 1.7.1 compiled on June 27 2008
Finished: SUCCESS

Suggested features

  1. Install tools from an SCM such as Subversion.
  2. Upload a tool archive directly into Jenkins' web GUI.
  3. Cache downloaded tools on master to avoid excess network traffic. (Already done for JDKs.)

Related: Tool Environment Plugin

Adding new versions

Jenkins gets the information where to download the versions via a JSON download from the internet.

The JSON data for the tools are stored in the files http://mirrors.jenkins-ci.org/updates/updates/, so adding a new version of an existing tool would require a path to the related file. The JSON data for some tools is created by backend/crawler in Jenkins sources.

More tools needed!

More things should extend ToolInstallation for this system to be really useful. An incomplete list:

  1. Languages & frameworks
    1. Ruby
    2. Groovy
    3. Rails
  2. Builders
    1. Rake
    2. NAnt
    3. MSBuild: JENKINS-4120
    4. Ant, Maven, Gradle, Buckminster, SCons, WAS Builder, RAD Builder, STAF seem done
  3. SCMs
    1. CVS
    2. Git
    3. Mercurial available as of 1.18
    4. unnecessary for SVN, which Jenkins runs from Java

Just in case you cannot find a ToolInstaller/ToolInstallation for your tool, there are also generic plugins which can be configured in flexible ways:

Write a comment…