Jenkins scripted multibranch pipeline

This commit is contained in:
Dominik Chilla 2019-06-14 22:02:43 +02:00
parent d5d2bc2263
commit 8f7b83d60a

51
Jenkinsfile vendored
View File

@ -1,29 +1,48 @@
node {
def app
pipeline {
agent any
/* stage('Clone repository') {
sh '/usr/bin/env'
checkout scm
}*/
stage('Build image') {
sh '/usr/bin/env'
/* Multi-Branch Pipeline works with env.BRANCH_NAME*/
app = docker.build("sos-milter:${env.BRANCH_NAME}","--pull --label BUILD_URL=${env.BUILD_URL} .")
environment {
dockerImage = ''
}
parameters {
string name: 'dockerRegistry', trim: true
}
stages {
stage('Build image') {
steps {
sh '/usr/bin/env'
script {
/* Multi-Branch Pipeline works with env.BRANCH_NAME*/
dockerImage = docker.build("sos-milter:${env.BRANCH_NAME}","--pull --label BUILD_URL=${env.BUILD_URL} .")
}
}
}
stage('Test image') {
app.inside {
steps {
script {
dockerImage.inside {
sh '/usr/bin/env'
sh '/bin/ps auxwwf'
}
}
stage('Push image') {
app.push()
}
}
stage('Push image') {
steps {
script {
docker.withRegistry(env.dockerRegistry) {
dockerImage.push()
}
}
}
}
stage('Cleanup') {
steps {
sh 'echo "TODO: cleanup!"'
}
}
}
}