From bdfa33d4a688e106b973b10f613da58aab7e520d Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Tue, 21 Jul 2020 22:12:30 +0800 Subject: [PATCH] Switched to node builder --- Dockerfile | 4 ++-- Jenkinsfile | 54 +++++++++++++++++++++++++++++++-------------------- entrypoint.sh | 0 3 files changed, 35 insertions(+), 23 deletions(-) mode change 100644 => 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 5a46c11..8e418c5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,8 +10,8 @@ ENV KUBE_LATEST_VERSION="v1.14.2" USER root RUN curl -L https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl \ - && chmod +x /usr/local/bin/kubectl -RUN zypper in -y expect + && chmod +x /usr/local/bin/kubectl && \ + zypper in -y expect COPY entrypoint.sh /home/step/ RUN chmod +x /home/step/entrypoint.sh diff --git a/Jenkinsfile b/Jenkinsfile index 3ca7bd9..868dbc3 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-step_bootstrap", 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_bootstrap" - - 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: 'https://git.ervine.org/jonny/x86_64-suse-step_bootstrap.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_bootstrap:0.14.3' + } } + } } + diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755