I was following this snippet to add to docker file for jenkins build agent (https://www.jenkins.io/doc/book/pipeline/docker/),
pipeline {
agent { dockerfile true }
stages {
stage('Test') {
steps {
sh 'node --version'
sh 'svn --version'
}
}
}
}
'dockerfile true' looks for the default Dockerfile. Is there a way to specify the docker file name as I don't want to use the default one because my settings would be different than the one already there?
Yes, you can absolutely specify the
dockerfilefile name in theagentdirective. An example of this (with other arguments for thedockerfileparameter inagent) would be:In the documentation for pipeline agent parameters, you can scroll down to the
dockerfileparameter to view the arguments for the parameter and how they allowagentcustomization.