The jenkins-agent enabled docker images defined here can be found on dockerhub.
Docker CICD builder agent for Jenkins.
Inspired by:
- https://wiki.tds.tieto.com/display/TDSKB/Executing+Jenkins+jobs+when+only+one+way+network+connection+exists
- https://support.cloudbees.com/hc/en-us/articles/115001771692-How-to-Create-Permanent-Agents-with-Docker#jnlpconnection
- https://github.com/cyrille-leclerc/java-build-tools-dockerfile
- https://github.com/dettonville/java-build-tools-dockerfile
- https://github.com/cloudbees/jnlp-slave-with-java-build-tools-dockerfile
- https://github.com/cloudbees/java-build-tools-dockerfile/blob/master/Dockerfile
- https://github.com/SeleniumHQ/docker-selenium/blob/master/Base/Dockerfile
- https://medium.com/@prashant.vats/jenkins-master-and-slave-with-docker-b993dd031cbd
- https://devopscube.com/docker-containers-as-build-slaves-jenkins/
- https://github.com/bibinwilson/jenkins-docker-slave
It can be used as a Jenkins inbound agent, for use with Jenkins Cloud plugins.
This Docker image is intended to be used in conjunction with a Docker container orchestration service such as
- Kubernetes (see Jenkins Kubernetes Plugin)
- Mesos (see Jenkins Mesos Plugin)
- Amazon EC2 Container Service
It can also be used as a "static" Jenkins agent connected to a Jenkins master by manually launching the Docker container.
Sample with the Jenkins Pipeline Maven Plugin.
node ("cicd-docker-agent") {
git "https://github.com/cloudbees-community/game-of-life"
withMaven(mavenSettingsConfig:'my-maven-settings') {
sh "mvn clean deploy"
}
}
The docker image enables Selenium tests bundling Firefox and starting selenium-server-standalone (listening on the default port 4444).
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
WebDriver webDriver = new RemoteWebDriver(DesiredCapabilities.firefox());
webDriver.get("http://www.python.org");
webDriver.getTitle();
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver = webdriver.Remote(
command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities=DesiredCapabilities.FIREFOX)
driver.get('http://python.org')
To run a Docker container
docker run cicd-docker-agent -url http://jenkins-server:port <secret> <agent name>
optional environment variables:
JENKINS_URL
: url for the Jenkins server, can be used as a replacement to-url
option, or to set alternate jenkins URLJENKINS_TUNNEL
: (HOST:PORT
) connect to this agent host and port instead of Jenkins server, assuming this one do route TCP traffic to Jenkins master. Useful when when Jenkins runs behind a load balancer, reverse proxy, etc.