I have a working Jenkins pipeline defined with agent {any}
.
But I want to try running the tests on a docker image. According to documentation I can do that the following way:
pipeline {
agent {
docker { image 'centos/python-27-centos7:latest' }
}
stages {
...
}
}
The problem is that my instance of Jenkins is offline and with this configuration it will try to docker pull
the image when running the project.
However I have the centos/python-27 image loaded in the docker (visible with docker images
and it can be run with docker run -i -t centos/python-27-centos7 /bin/bash
Is there any way I can configure the agent in Jenkins so it doesn't try to pull
the image from Docker Hub?
It is a Jenkins Cloud plugin for Docker. The aim of this docker plugin is to be able to use a Docker host to dynamically provision a docker container as a Jenkins agent node, let that run a single build, then tear-down that node, without the build process (or Jenkins job definition) requiring any awareness of docker.
Agent. An agent is typically a machine, or container, which connects to a Jenkins controller and executes tasks when directed by the controller. Artifact. An immutable file generated during a Build or Pipeline run which is archived onto the Jenkins Controller for later retrieval by users.
Pipeline adds a powerful set of automation tools onto Jenkins, supporting use cases that span from simple continuous integration to comprehensive continuous delivery pipelines. The steps to build, test, and deliver each application become part of the application itself, stored in a Jenkinsfile.
The Docker agent has an alwaysPull
flag you can set to false
or true
:
agent {
docker {
alwaysPull false
image 'foo/bar'
}
}
Jenkins has a Pipeline Syntax Generator that can help in these cases. In the Job menu on the left side, there is an icon for "Pipeline Syntax".
There you can see some settings to help you generate your pipeline directives.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With