At a minimum, the init script needs to install a Java runtime.
Custom prepared images are recommended if the initialization script is taking more than 20 minutes to execute.
Below are examples of initialization scripts:
1) Ubuntu
# Install Java
sudo apt-get -y update
sudo apt-get install -y openjdk-7-jdk
sudo apt-get -y update --fix-missing
sudo apt-get install -y openjdk-7-jdk
2) Windows w/JNLP
For Windows agents with JNLP launch, this script is a powershell script.
You can use this sample (update "username:apitoken" with your credentials)
Automatically passed to this script is:
First argument - Jenkins server URL
Second argument - VMName
Third argument - JNLP secret, required if the server has security enabled.
You need to install Java, download the slave jar file from: '[server url]jnlpJars/slave.jar'.
The server url should already have a trailing slash. Then execute the following to connect:
java.exe -jar [slave jar location] [-secret [client secret if required]] [server url]computer/[vm name]/slave-agent.jnlp