Jenkins declarative pipeline

This commit is contained in:
Dominik Chilla 2019-06-13 20:49:34 +02:00
parent dd696f43ad
commit 2cc02c1ffe

View File

@ -1,6 +1,11 @@
pipeline { pipeline {
environment{
dockerImage = ''
imageName = 'jenkins/sos-milter'
dockerRegistry = 'https://dockreg-fra.zwackl.de'
}
agent any agent any
def docker_image
stages { stages {
stage('Checkout SCM') { stage('Checkout SCM') {
@ -14,7 +19,7 @@ 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 */
docker_image = docker.build("jenkins/sos-milter") dockerImage = docker.build(imageName)
} }
} }
@ -22,7 +27,7 @@ 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 ;-) */
docker_image.inside { dockerImage.inside {
sh 'echo "Tests passed"' sh 'echo "Tests passed"'
} }
} }
@ -30,8 +35,8 @@ pipeline {
stage('Push image') { stage('Push image') {
steps { steps {
docker.withRegistry('https://dockreg-fra.zwackl.de') { docker.withRegistry(dockerRegistry) {
docker_image.push() dockerImage.push()
} }
} }
} }