1

I have a working Dockerfile that creates a build environment for a legacy app, and now I'd like to use that environment from Jenkins, ideally allowing for incremental builds.

The environment is too old to run a recent version of Java, which means it cannot be used as an agent directly.

Is there a way to run a series of build steps inside a container without the container itself running an agent?

1

According the the Jenkins docs, you could use your custom docker image as the execution environment, assuming the server Jenkins is running on has Docker installed/running.

pipeline {
    agent {
        docker { image 'your-custom-image' }
    }
    stages {
        stage('Build') {
            steps {
                sh 'commands to run in your docker image here'
            }
        }
    }
}
1
  • ah nice, I can even do "agent { dockerfile true }" and get the Dockerfile from the repo. Only downside is that this plugin uses the commandline docker client instead of the API. – Simon Richter Dec 20 '19 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.