Commit 1bb5ff14 authored by Emanuele Aina's avatar Emanuele Aina

Jenkinsfile: Workaround failure with multistage Dockerfile

The Jenkins Docker workflow plugin fails badly when trying to inspect
the built images when using a multi-stage `Dockerfile`.

That's because the plugins naively looks for the image name by taking
*all* the contents after `FROM `, which means it breaks whether a stage
name is introduced with `AS stagename` or even if more than a single
space is used after `FROM`.

See https://issues.jenkins-ci.org/browse/JENKINS-44609

Invoking `docker` directly as suggested on the JIRA issue works around
the problem.
Signed-off-by: Emanuele Aina's avatarEmanuele Aina <emanuele.aina@collabora.com>
parent b3f70611
Pipeline #3102 passed with stage
in 1 minute and 28 seconds
......@@ -13,9 +13,11 @@ def definitions = [
def buildContainer(directory, name, upload = false) {
docker.withRegistry("https://${registry}", registrycred) {
d = docker.build("${registry}/${name}", "--no-cache ${directory}")
// don't use docker.build() due to Jenkins failing on multi-stage Dockerfiles
// https://issues.jenkins-ci.org/browse/JENKINS-44609
sh "docker build -t ${registry}/${name} --no-cache ${directory}"
if (upload) {
d.push()
sh "docker push ${registry}/${name}"
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment