From da0ee7b28603850ffd1a0f80070d7b028dc019e4 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Mon, 20 Jul 2020 21:16:47 +0800 Subject: [PATCH] Use node bulder --- Jenkinsfile | 56 +++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index df10da2..37229b4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,30 +1,36 @@ -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-nzbhydra", 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/nzbhydra2" - - stage "publish" - app.push("${env.BUILD_NUMBER}") - app.push("2.25.0") - app.push("2.25") - app.push("2") - app.push("latest") +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 +""" + ) { - stage('Deploy on K8s'){ - sh "/usr/local/bin/kubectl -n media delete po nzbhydra-0" - } - } - catch (err) { - currentBuild.result = 'FAILURE' - } + node(POD_LABEL) { + stage('Build with Kaniko') { + git url: 'ssh://git@git.ervine.org/jonny/x86_64-alpine-nzbhydra.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/nzbhydra2:2.25.0 --destination=harbor.ervine.dev/library/x86_64/alpine/nzbhydra2:2.25 --destination=harbor.ervine.dev/library/x86_64/alpine/nzbget2:2' + } } + } }