alpine/Jenkinsfile

51 lines
2.2 KiB
Text
Raw Normal View History

2019-10-18 14:06:31 +00:00
project = "alpine"
repo = "zknt"
2020-05-30 01:26:20 +00:00
version = "3.12.0"
2019-10-18 14:06:31 +00:00
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
stages {
stage('Build image') {
steps {
2019-10-18 14:06:31 +00:00
withDockerRegistry([ credentialsId: registry_credentials, url: "https://"+registry ]) {
2018-11-26 17:59:18 +00:00
echo 'Starting to build docker image'
script {
2020-05-31 14:29:11 +00:00
def customImage = docker.build(registry+'/'+repo+'/'+project, "--build-arg VERSION=$version --build-arg DATE=$timeStamp .")
2019-10-18 14:06:31 +00:00
customImage.push(version)
customImage.push(version.split(/\./)[0,1].join('.'))
customImage.push(version.split(/\./)[0])
2018-12-02 18:08:53 +00:00
customImage.push("latest")
2019-10-22 08:22:16 +00:00
2020-08-26 13:08:52 +00:00
def io_registry_credentials = "3deeee3d-6fce-4430-98dd-9b4db56f43f7"
withDockerRegistry([ credentialsId: io_registry_credentials ]) {
2019-10-22 08:22:16 +00:00
def official_image = repo+'/'+project+':'+version.split(/\./)[0,1].join('.')
sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + official_image
sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + official_image.split(/\:/)[0]
sh "docker push " + official_image
sh "docker push " + official_image.split(/\:/)[0]
}
2020-08-26 13:02:34 +00:00
2020-08-26 13:08:52 +00:00
def quay_credentials= "18fb6f7e-c6bc-4d06-9bf9-08c2af6bfc1a"
withDockerRegistry([ credentialsId: quay_credentials, url: "https://quay.io" ]) {
def official_image = 'quay.io/'+repo+'/'+project+':'+version.split(/\./)[0,1].join('.')
2020-08-26 13:02:34 +00:00
sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + official_image
sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + official_image.split(/\:/)[0]
sh "docker push " + official_image
sh "docker push " + official_image.split(/\:/)[0]
}
2018-11-26 17:59:18 +00:00
}
}
}
}
}
2019-10-18 14:06:31 +00:00
post {
always {
emailext body: 'build finished', subject: '[jenkins] docker '+project+': ' + currentBuild.result, to: 'cg@zknt.org', from: 'sysadm@zknt.org', attachLog: true
}
}
2018-11-26 17:59:18 +00:00
}