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 apt-get -y update
sudo apt-get install -y default-jdk
java -version
# Install Git
sudo apt-get install -y git
# Install Maven
MAVEN_VERSION=3.9.9
sudo curl -O https://downloads.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz
sudo tar zxvf apache-maven-${MAVEN_VERSION}-bin.tar.gz -C /opt/
sudo ln -s /opt/apache-maven-${MAVEN_VERSION}/bin/mvn /usr/bin/mvn
mvn --version
# 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
sudo docker --version
You can use this sample.
Java, the agent jar and connecting to Jenkins are required, others are optional.
You can use this sample.
Java is required, others are optional.
We recommend to use SSH rather than inbound agent. It's simpler to setup and you get much clearer logs.
You can use this sample.
Java, the agent jar and connecting to Jenkins 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 [agent jar location] [-secret [client secret if required]] [server url]computer/[vm name]/jenkins-agent.jnlp