From fab714379c5b139d6ff6c6efc5ae10ec7f786e2c Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Fri, 2 Dec 2022 21:36:03 -0600 Subject: [PATCH] ci: Build in Kubernetes Can't use the official Zola container image because it doesn't have a shell, so Jenkins can't run commands in it. --- ci/Containerfile | 15 --------------- ci/Jenkinsfile | 22 ++++++++++++++-------- ci/build.sh | 3 +-- ci/podTemplate.yaml | 20 ++++++++++++++++++++ 4 files changed, 35 insertions(+), 25 deletions(-) delete mode 100644 ci/Containerfile create mode 100644 ci/podTemplate.yaml diff --git a/ci/Containerfile b/ci/Containerfile deleted file mode 100644 index f7a735b..0000000 --- a/ci/Containerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM alpine - -RUN echo jenkins:*:3000018:3000017::/var/lib/jenkins:/bin/bash >> /etc/passwd - -RUN apk update && \ - apk add zola --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ && \ - apk add \ - openssh-client-default \ - python3 \ - py3-ruamel.yaml \ - rsync \ - && \ - rm -rf /var/cache/apk/* - -COPY ssh_known_hosts /etc/ssh/ssh_known_hosts diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index 8184b16..a70b166 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -2,9 +2,8 @@ pipeline { agent { - dockerfile { - dir 'ci' - filename 'Containerfile' + kubernetes { + yamlFile 'ci/podTemplate.yaml' } } @@ -12,22 +11,29 @@ pipeline { disableConcurrentBuilds() } - triggers { - pollSCM '' + environment { + HOME = "${env.WORKSPACE}" } stages { stage('Build') { steps { - sh '. ci/build.sh' + container('zola') { + sh 'zola build --base-url /' + } + container('python') { + sh '. ci/build.sh' + } } } stage('Publish') { steps { - sshagent(['jenkins-web']) { - sh '. ci/publish.sh' + container('rsync') { + sshagent(['jenkins-web']) { + sh '. ci/publish.sh' + } } } } diff --git a/ci/build.sh b/ci/build.sh index df57139..734e263 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -1,5 +1,4 @@ -zola build --base-url / - +python3 -m pip install --user ruamel.yaml python3 /dev/fd/3 < songquotes.yml > public/songquotes.json 3<