Jenkins declarative pipeline

This commit is contained in:
Dominik Chilla 2019-06-13 20:54:22 +02:00
parent 2cc02c1ffe
commit 1c584584dc

View File

@ -1,6 +1,6 @@
pipeline { pipeline {
environment{ environment {
dockerImage = '' imageObject = ''
imageName = 'jenkins/sos-milter' imageName = 'jenkins/sos-milter'
dockerRegistry = 'https://dockreg-fra.zwackl.de' dockerRegistry = 'https://dockreg-fra.zwackl.de'
} }
@ -19,7 +19,9 @@ pipeline {
sh '/usr/bin/env' sh '/usr/bin/env'
/* This builds the actual image; synonymous to /* This builds the actual image; synonymous to
* docker build on the command line */ * docker build on the command line */
dockerImage = docker.build(imageName) script {
imageObject = docker.build(imageName)
}
} }
} }
@ -27,18 +29,28 @@ pipeline {
steps { steps {
/* Ideally, we would run a test framework against our image. /* Ideally, we would run a test framework against our image.
* For this example, we're using a Volkswagen-type approach ;-) */ * For this example, we're using a Volkswagen-type approach ;-) */
dockerImage.inside { script {
imageObject.inside {
sh 'echo "Tests passed"' sh 'echo "Tests passed"'
} }
} }
} }
}
stage('Push image') { stage('Push image') {
steps { steps {
script {
docker.withRegistry(dockerRegistry) { docker.withRegistry(dockerRegistry) {
dockerImage.push() imageObject.push()
} }
} }
} }
} }
stage('Cleanup') {
steps {
sh 'echo "TODO: cleanup!"'
}
}
}
} }