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, Java is required, others are optional:
# Install Java
sudo add-apt-repository ppa:openjdk-r/ppa -y
sudo apt-get -y update
sudo apt-get install openjdk-8-jre openjdk-8-jre-headless openjdk-8-jdk -y
# Install Git
sudo apt-get install -y git
# Install Maven
sudo curl -O http://www-eu.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz
sudo tar zxvf apache-maven-3.5.0-bin.tar.gz -C /opt/
sudo ln -s /opt/apache-maven-3.5.0/bin/mvn /usr/bin/mvn
# Install Docker
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get -y update
sudo apt-get install -y docker-ce
# Replace ${ADMIN} with admin username.
sudo gpasswd -a ${ADMIN} docker
sudo chmod g+rw /var/run/docker.sock
You can use this sample.
Java is required, others are optional.
We recommend to use SSH rather than JNLP. For you need less init codes and get much clearer logs.
For Windows agents with JNLP launch, this script is a powershell script.
You can use this sample.
Java, slaves and connection are required, others are optional.
Arguments automatically passed to this script are:
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