jenkins agent as docker container linked to jenkins master with maven

Опубликовано: 07 Октябрь 2024
на канале: Ahmed Salah El-Din
215
like

This shows how to run a Jenkins agent as a Docker container connected to a Jenkins master node running in Apache Tomcat server

Create a slave node where:

Remote root directory of the agent is set to /home/jenkins while creating the node, which is the default home directory for jenkins user inside the container, so the user jenkins is the owner of this directory, it will then be safe to run using this directory as the root directory of the node, using a different path may result in failure as the user jenkins does not have the ownership of all directories.

From Global Security section, make sure that agents can connect to port 50000

From `Global Tool Configuration`, it might be required to check the option `install automatically` for `Maven` tool to allow installation inside the agent, otherwise, you will have to configure `Tool Locations` in `node configuration`

Agent container

docker run -d -v slave-data:/home/jenkins --name jenkins-slave jenkinsci/jnlp-slave -url http://TOMCAT-SERVER:8080/jenkins CONNECTION-HASH slave-container