Search code examples
dockerimagejenkinscloud

Specifying the Docker image to use when running a build with Jenkins


I am using the Jenksci/Docker-Plugin plugin with Jenkins 2.401.3, but I have run into a limitation that if I could overcome, would greatly reduce complication.

There doesn't seem to be a way to programmatically choose which Docker image will be used when the build is invoked. I want to be able to specify the use of the Cloud Docker build slave, but I also want to be able to specify the Docker image. That way I can have one Cloud Node definition that can be used with many Docker images, rather than many Cloud Node definitions.

How can this be done?


Solution

  • There is an experimental feature that allows you to specify the image to use - dockerNode

    dockerNode('jenkins/jnlp-agent-maven') {
        ...
    }