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:
# Install Java
sudo apt-get -y update
sudo apt-get install -y openjdk-7-jdk
# Install Git
sudo apt-get install -y git
For Windows agents with JNLP launch, this script is a powershell script.
You can use this sample.
Arguments automatically passed to this script are:
You need to install Java, download the slave jar file from: '[server url]jnlpJars/slave.jar
'.
# Download and Install Java
$source = "http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-windows-x64.exe"
$destination = "C:\jdk-8u131-windows-x64.exe"
$client = new-object System.Net.WebClient
$cookie = "oraclelicense=accept-securebackup-cookie"
$client.Headers.Add([System.Net.HttpRequestHeader]::Cookie, $cookie)
$client.downloadFile($source, $destination)
$proc = Start-Process -FilePath $destination -ArgumentList "/s"m -Wait -PassThru
$proc.WaitForExit()
[System.Environment]::SetEnvironmentVariable("JAVA_HOME", "c:\Program Files\Java\jdk1.8.0_131", "Machine")
[System.Environment]::SetEnvironmentVariable("PATH", $Env:Path + ";c:\Program Files\Java\jdk1.8.0_131\bin", "Machine")
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