alpine/Jenkinsfile

79 lines
3.2 KiB
Text
Raw Normal View History

2020-10-28 15:46:30 +00:00
version = "3.12.1"
2019-10-18 14:06:31 +00:00
project = "alpine"
repo = "zknt"
registry = "reg.zknt.org"
2019-12-19 16:33:59 +00:00
registry_credentials = "6ff44976-23cd-4cc2-902c-de8c340e65e5"
2020-05-31 14:29:11 +00:00
timeStamp = Calendar.getInstance().getTime().format('YYYY-MM-dd',TimeZone.getTimeZone('UTC'))
2019-10-18 14:06:31 +00:00
2018-11-26 17:59:18 +00:00
pipeline {
agent any
2020-10-28 15:46:30 +00:00
stages {
stage('Build image') {
steps {
withDockerRegistry([ credentialsId: registry_credentials, url: "https://"+registry ]) {
script {
def customImage = docker.build(registry+'/'+repo+'/'+project, "--pull --build-arg VERSION=$version --build-arg DATE=$timeStamp .")
customImage.push(version)
customImage.push("latest")
customImage.push("3.12")
2019-10-22 08:22:16 +00:00
2020-10-28 15:46:30 +00:00
def io_registry_credentials = "3deeee3d-6fce-4430-98dd-9b4db56f43f7"
withDockerRegistry([ credentialsId: io_registry_credentials ]) {
def io_registry_image = repo + '/' + project + ':' + version
sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + io_registry_image
sh "docker push " + io_registry_image
sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + io_registry_image.split(/\:/)[0] + "latest"
sh "docker push " + io_registry_image.split(/\:/)[0] + "latest"
sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + io_registry_image.split(/\:/)[0] + "3.12"
sh "docker push " + io_registry_image.split(/\:/)[0] + "3.12"
}
2020-08-26 13:02:34 +00:00
2020-10-28 15:46:30 +00:00
def quay_credentials= "18fb6f7e-c6bc-4d06-9bf9-08c2af6bfc1a"
withDockerRegistry([ credentialsId: quay_credentials, url: "https://quay.io" ]) {
def quay_image = 'quay.io/' + repo + '/' + project + ':' + version
sh "docker push " + quay_image
sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + official_image.split(/\:/)[0] + "latest"
sh "docker push " + official_image.split(/\:/)[0] + "latest"
sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + official_image.split(/\:/)[0] + "3.12"
sh "docker push " + official_image.split(/\:/)[0] + "3.12"
}
2020-08-26 13:02:34 +00:00
}
2018-11-26 17:59:18 +00:00
}
}
}
}
2019-10-18 14:06:31 +00:00
post {
2020-10-23 17:49:27 +00:00
success {
sh """docker rmi -f \$(docker images -q $registry/$repo/$project:$version)"""
sh """for image in \$(grep FROM Dockerfile | cut -d ' ' -f 2); do docker rmi -f \$(docker images -q \${image}); done"""
}
2019-10-18 14:06:31 +00:00
always {
2020-10-28 15:46:30 +00:00
emailext body: 'build finished', subject: '[jenkins] docker '+project+'('+version+'): ' + currentBuild.result, to: 'cg@zknt.org', from: 'sysadm@zknt.org', attachLog: true
2019-10-18 14:06:31 +00:00
}
}
2020-10-23 17:49:27 +00:00
options {
buildDiscarder(BuildHistoryManager([
[
conditions: [
BuildResult(matchFailure: true)
],
matchAtMost: 4,
continueAfterMatch: false
],
[
conditions: [
BuildResult(matchSuccess: true)
],
matchAtMost: 4,
continueAfterMatch: false
],
[
conditions: [
BuildResult(matchSuccess: true, matchFailure: true)
],
actions: [DeleteBuild()]
]
]))
}
2020-10-28 15:46:30 +00:00
}