Jenkins scripted multibranch pipeline

This commit is contained in:
Dominik Chilla 2019-06-14 22:14:41 +02:00
parent 8f7b83d60a
commit 9c0b4b943a

18
Jenkinsfile vendored
View File

@ -1,21 +1,24 @@
pipeline { pipeline {
agent any agent any
environment {
dockerImage = ''
}
parameters { parameters {
string name: 'dockerRegistry', trim: true string name: 'dockerRegistry', trim: true
} }
environment {
dockerImage = ''
imageName = 'sos-milter'
}
stages { stages {
stage('Build image') { stage('Build image') {
steps { steps {
sh '/usr/bin/env' sh '/usr/bin/env'
script { script {
/* Multi-Branch Pipeline works with env.BRANCH_NAME*/ dockerImage = docker.build(
dockerImage = docker.build("sos-milter:${env.BRANCH_NAME}","--pull --label BUILD_URL=${env.BUILD_URL} .") "${env.imageName}:${env.BRANCH_NAME}",
"--pull --label BUILD_URL=${env.BUILD_URL} ."
)
} }
} }
} }
@ -23,6 +26,7 @@ pipeline {
steps { steps {
script { script {
dockerImage.inside { dockerImage.inside {
sh 'echo "INSIDE CONTAINER!"'
sh '/usr/bin/env' sh '/usr/bin/env'
sh '/bin/ps auxwwf' sh '/bin/ps auxwwf'
} }
@ -40,7 +44,7 @@ pipeline {
} }
stage('Cleanup') { stage('Cleanup') {
steps { steps {
sh 'echo "TODO: cleanup!"' sh '/usr/bin/docker rmi ${env.imageName}:${env.BRANCH_NAME}'
} }
} }
} }