generate jenkinsfile
dockers/debian/pipeline/head Build queued... Details

This commit is contained in:
chris 2020-10-28 17:30:37 +01:00
parent caf07e253a
commit a1264646e0
3 changed files with 46 additions and 25 deletions

View File

@ -13,8 +13,8 @@ RUN set -xe;\
rm -rf /var/lib/apt/lists/*
FROM bootstrapped as toolbuilder
ARG GOSU_VERSION
ARG DUMB_INIT_VERSION
ENV GOSU_VERSION="1.12"
ENV DUMB_INIT_VERSION="1.2.2"
RUN set -xe;\
apt-get update &&\
apt-get install -y git golang &&\
@ -33,8 +33,8 @@ RUN set -xe;\
FROM bootstrapped
ARG DATE
ARG GOSU_VERSION
ARG DUMB_INIT_VERSION
ENV GOSU_VERSION="1.12"
ENV DUMB_INIT_VERSION="1.2.2"
COPY --from=toolbuilder /build/build /usr/local/sbin/gosu
COPY --from=toolbuilder /dumb-init /usr/local/sbin/dumb-init
COPY apt-install /bin/apt-install

58
Jenkinsfile vendored
View File

@ -1,37 +1,54 @@
gosu_version = "1.12"
dumb_init_version = "1.2.2"
version = "10"
project = "debian"
repo = "zknt"
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: "6ff44976-23cd-4cc2-902c-de8c340e65e5", url: "https://reg.zknt.org" ]) {
script {
def customImage = docker.build("reg.zknt.org/zknt/debian", "--pull --build-arg DATE=$timeStamp --build-arg GOSU_VERSION=$gosu_version --build-arg DUMB_INIT_VERSION=$dumb_init_version --no-cache .")
customImage.push("buster")
customImage.push("stable")
customImage.push("10")
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("buster")
customImage.push("stable")
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] + "buster"
sh "docker push " + io_registry_image.split(/\:/)[0] + "buster"
sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + io_registry_image.split(/\:/)[0] + "stable"
sh "docker push " + io_registry_image.split(/\:/)[0] + "stable"
}
registry_credentials = "3deeee3d-6fce-4430-98dd-9b4db56f43f7"
withDockerRegistry([ credentialsId: registry_credentials ]) {
def official_image = 'zknt/debian:buster'
sh "docker image tag reg.zknt.org/zknt/debian:buster " + official_image
sh "docker push " + official_image
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] + "buster"
sh "docker push " + official_image.split(/\:/)[0] + "buster"
sh "docker image tag " + registry+'/'+repo+'/'+project+':'+version + ' ' + official_image.split(/\:/)[0] + "stable"
sh "docker push " + official_image.split(/\:/)[0] + "stable"
}
}
}
}
}
}
}
post {
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"""
}
always {
emailext body: 'build finished', subject: '[jenkins] docker debian: ' + 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 {
@ -47,7 +64,7 @@ pipeline {
conditions: [
BuildResult(matchSuccess: true)
],
matchAtMost: 2,
matchAtMost: 4,
continueAfterMatch: false
],
[
@ -58,5 +75,4 @@ pipeline {
]
]))
}
}
}

5
build.yaml Normal file
View File

@ -0,0 +1,5 @@
version: 10
project: debian
additional_tags:
- buster
- stable