mirror of
https://github.com/chillout2k/sos-milter.git
synced 2025-12-12 18:10:18 +00:00
Jenkins scripted multibranch pipeline
This commit is contained in:
parent
d780007d2c
commit
efd113b9de
54
Jenkinsfile.declarative.multibranch
Normal file
54
Jenkinsfile.declarative.multibranch
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
parameters {
|
||||||
|
string defaultValue: 'https', name: 'dockerRegistryScheme', trim: true
|
||||||
|
string defaultValue: 'change.me', name: 'dockerRegistryRepo', trim: true
|
||||||
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
dockerImage = ''
|
||||||
|
imageName = 'sos-milter'
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Build image') {
|
||||||
|
steps {
|
||||||
|
sh '/usr/bin/env'
|
||||||
|
script {
|
||||||
|
dockerImage = docker.build(
|
||||||
|
"${env.imageName}:${env.BRANCH_NAME}",
|
||||||
|
"--pull --label BUILD_URL=${env.BUILD_URL} ."
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Test image') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
dockerImage.inside {
|
||||||
|
sh 'echo "INSIDE CONTAINER!"'
|
||||||
|
sh '/usr/bin/env'
|
||||||
|
sh '/bin/ps auxwwf'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Push image') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
docker.withRegistry("${env.dockerRegistryScheme}://${env.dockerRegistryRepo}") {
|
||||||
|
dockerImage.push()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Cleanup') {
|
||||||
|
steps {
|
||||||
|
sh '/usr/bin/docker rmi -f "${imageName}:${BRANCH_NAME}"'
|
||||||
|
sh '/usr/bin/docker rmi -f "${dockerRegistryRepo}/${imageName}:${BRANCH_NAME}"'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user