From 90f3292d9dcdbd565d1e0dbe198ccc1212d49ea5 Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 28 Oct 2020 16:46:30 +0100 Subject: [PATCH] generate jenkinsfile --- Jenkinsfile | 61 +++++++++++++++++++++++++++-------------------------- build.yaml | 5 +++++ 2 files changed, 36 insertions(+), 30 deletions(-) create mode 100644 build.yaml diff --git a/Jenkinsfile b/Jenkinsfile index b557eab..24b4fcb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,46 +1,47 @@ +version = "3.12.1" project = "alpine" repo = "zknt" -version = "3.12.1" registry = "reg.zknt.org" registry_credentials = "6ff44976-23cd-4cc2-902c-de8c340e65e5" timeStamp = Calendar.getInstance().getTime().format('YYYY-MM-dd',TimeZone.getTimeZone('UTC')) pipeline { agent any - stages { - stage('Build image') { - steps { - withDockerRegistry([ credentialsId: registry_credentials, url: "https://"+registry ]) { - echo 'Starting to build docker image' - script { - def customImage = docker.build(registry+'/'+repo+'/'+project, "--pull --build-arg VERSION=$version --build-arg DATE=$timeStamp .") - customImage.push(version) - customImage.push(version.split(/\./)[0,1].join('.')) - customImage.push(version.split(/\./)[0]) - customImage.push("latest") + 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") - def io_registry_credentials = "3deeee3d-6fce-4430-98dd-9b4db56f43f7" - withDockerRegistry([ credentialsId: io_registry_credentials ]) { - 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] - } + 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" + } - 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('.') - 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] + 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" + } } } } } } - } post { success { @@ -48,7 +49,7 @@ pipeline { sh """for image in \$(grep FROM Dockerfile | cut -d ' ' -f 2); do docker rmi -f \$(docker images -q \${image}); done""" } always { - emailext body: 'build finished', subject: '[jenkins] docker '+project+': ' + currentBuild.result, to: 'cg@zknt.org', from: 'sysadm@zknt.org', attachLog: true + emailext body: 'build finished', subject: '[jenkins] docker '+project+'('+version+'): ' + currentBuild.result, to: 'cg@zknt.org', from: 'sysadm@zknt.org', attachLog: true } } options { @@ -75,4 +76,4 @@ pipeline { ] ])) } -} +} \ No newline at end of file diff --git a/build.yaml b/build.yaml new file mode 100644 index 0000000..65cfccc --- /dev/null +++ b/build.yaml @@ -0,0 +1,5 @@ +version: 3.12.1 +project: alpine +additional_tags: + - latest + - 3.12