From 50b608438a037459db81b5864ad332741f89bd86 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Tue, 21 Jul 2020 22:07:55 +0800 Subject: [PATCH] Switched to node builder --- Dockerfile | 7 +++---- Jenkinsfile | 54 ++++++++++++++++++++++++++++++++--------------------- start.sh | 0 3 files changed, 36 insertions(+), 25 deletions(-) mode change 100644 => 100755 start.sh diff --git a/Dockerfile b/Dockerfile index 2f613c8..8ab2f45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Base on latest (edge) alpine image -FROM opensuse/leap:15.1 +FROM opensuse/leap:15.2 MAINTAINER “Jonathan Ervine” @@ -27,9 +27,8 @@ RUN wget https://github.com/smallstep/certificates/releases/download/v$STEP_VERS RUN wget https://github.com/smallstep/cli/releases/download/v$STEP_VERSION/step_linux_$STEP_VERSION\_amd64.tar.gz && \ tar zxvf step_linux_$STEP_VERSION\_amd64.tar.gz -C /tmp/ && \ - mv /tmp/step_$STEP_VERSION/bin/step /usr/local/bin/ - -RUN rm -rf step_linux_$STEP_VERSION\_amd64.tar.gz /tmp/step_$STEP_VERSION /tmp/step-certificates_$STEP_VERSION + mv /tmp/step_$STEP_VERSION/bin/step /usr/local/bin/ && \ + rm -rf step_linux_$STEP_VERSION\_amd64.tar.gz /tmp/step_$STEP_VERSION /tmp/step-certificates_$STEP_VERSION EXPOSE 9000/tcp diff --git a/Jenkinsfile b/Jenkinsfile index b1c01d4..c2eaac1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,23 +1,35 @@ -node("docker-node") { - docker.withRegistry('https://harbor.ervine.dev', 'jenkins-to-harbor') { - - git branch: "master", url: "ssh://git@git.ervine.org:2222/jonny/x86_64-suse-stepCA", 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/suse/stepca" - - stage "publish" - app.push("${env.BUILD_NUMBER}") - app.push("latest") - app.push("0.14.3") - } - 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-suse-stepCA.git', credentialsId: 'jenkins-to-git' + container('kaniko') { + sh '/kaniko/executor -f `pwd`/Dockerfile -c `pwd` --cache=true --destination=harbor.ervine.dev/library/x86_64/suse/stepca:0.14.3' + } } + } } + diff --git a/start.sh b/start.sh old mode 100644 new mode 100755