Run Jenkins Job in a container

Of course, the answer is Yes, this is possible.

Given the broad type of question, I can only give pointers.

jenkins-pipeline offers a nice way to describe your pipelines as code. The docker plugin also integrates with that, so that you can run your jobs within a container, e.g.

// select a slave based on the label 'docker'
node('docker') {
  stage "Run in container (e.g. the php-7)"
  docker.image('php:7').inside {
    // run your command
    sh "phpunit"
  }
}

There are couple of resources out there regarding jenkins-pipelinedocker that will get you started.


I found the plugin I was looking for.

https://plugins.jenkins.io/docker-custom-build-environment/

This will do what I want. It will allow me to run my jobs in a container. So far, it is working well.