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
d83059fd9c
commit
f721d5be1a
24
Jenkinsfile
vendored
24
Jenkinsfile
vendored
@ -4,11 +4,11 @@ pipeline {
|
|||||||
parameters {
|
parameters {
|
||||||
string defaultValue: 'https', name: 'dockerRegistryScheme', trim: true
|
string defaultValue: 'https', name: 'dockerRegistryScheme', trim: true
|
||||||
string defaultValue: 'example.com', name: 'dockerRegistryRepo', trim: true
|
string defaultValue: 'example.com', name: 'dockerRegistryRepo', trim: true
|
||||||
|
string defaultValue: 'sos-milter', name: 'imageName', trim: true
|
||||||
}
|
}
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
dockerImage = ''
|
dockerImageObj = ''
|
||||||
imageName = 'sos-milter'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
@ -16,7 +16,7 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
sh '/usr/bin/env'
|
sh '/usr/bin/env'
|
||||||
script {
|
script {
|
||||||
dockerImage = docker.build(
|
dockerImageObj = docker.build(
|
||||||
"${env.imageName}:${env.BRANCH_NAME}",
|
"${env.imageName}:${env.BRANCH_NAME}",
|
||||||
"--pull --label BUILD_URL=${env.BUILD_URL} ."
|
"--pull --label BUILD_URL=${env.BUILD_URL} ."
|
||||||
)
|
)
|
||||||
@ -26,7 +26,7 @@ pipeline {
|
|||||||
stage('Test image') {
|
stage('Test image') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
dockerImage.inside {
|
dockerImageObj.inside {
|
||||||
sh 'echo "INSIDE CONTAINER!"'
|
sh 'echo "INSIDE CONTAINER!"'
|
||||||
sh '/usr/bin/env'
|
sh '/usr/bin/env'
|
||||||
sh '/bin/ps auxwwf'
|
sh '/bin/ps auxwwf'
|
||||||
@ -38,15 +38,25 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
docker.withRegistry("${env.dockerRegistryScheme}://${env.dockerRegistryRepo}") {
|
docker.withRegistry("${env.dockerRegistryScheme}://${env.dockerRegistryRepo}") {
|
||||||
dockerImage.push()
|
dockerImageObj.push()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Cleanup') {
|
stage('Cleanup') {
|
||||||
steps {
|
steps {
|
||||||
sh '/usr/bin/docker rmi -f "${imageName}:${BRANCH_NAME}"'
|
/* The default is to reuse the local images for future builds. The reason
|
||||||
sh '/usr/bin/docker rmi -f "${dockerRegistryRepo}/${imageName}:${BRANCH_NAME}"'
|
for this is quite simple! It´s much easier to prune local images from
|
||||||
|
disk than pushed images from the (cheap) docker registry! */
|
||||||
|
/* Uncomment the following directives if you want your build host to stay
|
||||||
|
clean from local docker images after successfull push. But, there is a
|
||||||
|
caveat if you do so! Each build job produces at least one new image layer
|
||||||
|
which gets pushed to the registry. This could blow up your registry after
|
||||||
|
a couple of time! For garbage collection check this out:
|
||||||
|
https://docs.docker.com/registry/garbage-collection/ */
|
||||||
|
/* echo "Remove local docker images after successfull push to registry..." */
|
||||||
|
/* sh '/usr/bin/docker rmi -f "${imageName}:${BRANCH_NAME}"' */
|
||||||
|
/* sh '/usr/bin/docker rmi -f "${dockerRegistryRepo}/${imageName}:${BRANCH_NAME}"' */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,11 +4,11 @@ pipeline {
|
|||||||
parameters {
|
parameters {
|
||||||
string defaultValue: 'https', name: 'dockerRegistryScheme', trim: true
|
string defaultValue: 'https', name: 'dockerRegistryScheme', trim: true
|
||||||
string defaultValue: 'example.com', name: 'dockerRegistryRepo', trim: true
|
string defaultValue: 'example.com', name: 'dockerRegistryRepo', trim: true
|
||||||
|
string defaultValue: 'sos-milter', name: 'imageName', trim: true
|
||||||
}
|
}
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
dockerImage = ''
|
dockerImageObj = ''
|
||||||
imageName = 'sos-milter'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
@ -16,7 +16,7 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
sh '/usr/bin/env'
|
sh '/usr/bin/env'
|
||||||
script {
|
script {
|
||||||
dockerImage = docker.build(
|
dockerImageObj = docker.build(
|
||||||
"${env.imageName}:${env.BRANCH_NAME}",
|
"${env.imageName}:${env.BRANCH_NAME}",
|
||||||
"--pull --label BUILD_URL=${env.BUILD_URL} ."
|
"--pull --label BUILD_URL=${env.BUILD_URL} ."
|
||||||
)
|
)
|
||||||
@ -26,7 +26,7 @@ pipeline {
|
|||||||
stage('Test image') {
|
stage('Test image') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
dockerImage.inside {
|
dockerImageObj.inside {
|
||||||
sh 'echo "INSIDE CONTAINER!"'
|
sh 'echo "INSIDE CONTAINER!"'
|
||||||
sh '/usr/bin/env'
|
sh '/usr/bin/env'
|
||||||
sh '/bin/ps auxwwf'
|
sh '/bin/ps auxwwf'
|
||||||
@ -38,15 +38,25 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
docker.withRegistry("${env.dockerRegistryScheme}://${env.dockerRegistryRepo}") {
|
docker.withRegistry("${env.dockerRegistryScheme}://${env.dockerRegistryRepo}") {
|
||||||
dockerImage.push()
|
dockerImageObj.push()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Cleanup') {
|
stage('Cleanup') {
|
||||||
steps {
|
steps {
|
||||||
sh '/usr/bin/docker rmi -f "${imageName}:${BRANCH_NAME}"'
|
/* The default is to reuse the local images for future builds. The reason
|
||||||
sh '/usr/bin/docker rmi -f "${dockerRegistryRepo}/${imageName}:${BRANCH_NAME}"'
|
for this is quite simple! It´s much easier to prune local images from
|
||||||
|
disk than pushed images from the (cheap) docker registry! */
|
||||||
|
/* Uncomment the following directives if you want your build host to stay
|
||||||
|
clean from local docker images after successfull push. But, there is a
|
||||||
|
caveat if you do so! Each build job produces at least one new image layer
|
||||||
|
which gets pushed to the registry. This could blow up your registry after
|
||||||
|
a couple of time! For garbage collection check this out:
|
||||||
|
https://docs.docker.com/registry/garbage-collection/ */
|
||||||
|
/* echo "Remove local docker images after successfull push to registry..." */
|
||||||
|
/* 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