From the official instructions on building Docker images with Jenkins Pipeline:
The build()
method builds the Dockerfile
in the current directory
by default. This can be overridden by providing a directory path
containing a Dockerfile
as the second argument of the build()
method, for example:
node {
checkout scm
def testImage = docker.build("test-image", "./dockerfiles/test")
testImage.inside {
sh 'make test'
}
}
I'm not sure if you can create a Pipeline (i.e. Jenkinsfile) with this exact configuration through the Blue Ocean UI, but I would imagine you can. However, I personally have found using Blue Ocean to create pipelines to be finicky at best, so I would recommend going over a Jenkinsfile created by Blue Ocean and making tweaks and adjustments by hand anyway. This would give you the opportunity to adjust the Dockerfile location even if you aren't able to do it via Blue Ocean.