From 4e3c0f60c56d4bda5eded8e08c3cfdbd838f2985 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Mon, 20 Jul 2020 15:29:21 +0800 Subject: [PATCH] Using node builder --- Dockerfile | 4 ++-- Jenkinsfile | 56 ++++++++++++++++++++++++++++++----------------------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index a2f781c..c0c4bf6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Base on latest (edge) alpine image -FROM harbor.ervine.dev/library/x86_64/alpine/alpine-3.11 +FROM harbor.ervine.dev/library/x86_64/alpine/alpine:3.12 MAINTAINER “Jonathan Ervine” @@ -14,7 +14,7 @@ ENV LANG='en_US.UTF-8' \ RUN echo http://dl-4.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \ apk update && \ - apk -U upgrade && \ + apk -U upgrade --ignore alpine-baselayout && \ apk -U add \ transmission-daemon && \ wget https://github.com/Secretmapper/combustion/archive/release.zip && \ diff --git a/Jenkinsfile b/Jenkinsfile index 5816a86..def7e40 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,27 +1,35 @@ -node("docker-node") { - docker.withRegistry('https://harbor.ervine.dev', 'jenkins-to-harbor') { - - git branch: "3.11.6", url: "ssh://git@git.ervine.org/jonny/x86_64-alpine-transmission", credentialsId: 'jenkins-to-git' - - sh "git rev-parse HEAD > .git/commit-id" - def commit_id = readFile('.git/commit-id').trim() - println commit_id - - try { - stage "build" - def app = docker.build "library/x86_64/alpine/transmission" - - stage "publish" - app.push("${env.BUILD_NUMBER}") - app.push("latest") - - stage('Deploy on K8s'){ - sh "/usr/local/bin/kubectl -n media delete po transmission-0" - } - } - catch (err) { - currentBuild.result = 'FAILURE' - } +podTemplate(yaml: """ +kind: Pod +spec: + containers: + - name: kaniko + image: gcr.io/kaniko-project/executor:debug-539ddefcae3fd6b411a95982a830d987f4214251 + imagePullPolicy: Always + command: + - /busybox/cat + tty: true + volumeMounts: + - name: jenkins-docker-cfg + mountPath: /kaniko/.docker + volumes: + - name: jenkins-docker-cfg + projected: + sources: + - secret: + name: regcred + items: + - key: .dockerconfigjson + path: config.json +""" + ) { + node(POD_LABEL) { + stage('Build with Kaniko') { + git url: 'ssh://git@git.ervine.org/jonny/x86_64-alpine-transmission.git', credentialsId: 'jenkins-to-git' + container('kaniko') { + sh '/kaniko/executor -f `pwd`/Dockerfile -c `pwd` --cache=true --destination=harbor.ervine.dev/library/x86_64/alpine/transmission:latest --destination=harbor.ervine.dev/library/x86_64/alpine/transmission:3.12.0 --destination=harbor.ervine.dev/library/x86_64/alpine/transmission:3.12' + } } + } } +