From d84603a6ac3ffa0db4bd8bab178786e2b869dd21 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Fri, 19 Jan 2024 10:27:38 -0600 Subject: [PATCH] ci: Use containerimages pipeline library The `buildContainerImage2` function now accepts a `pi` argument, which controls whether or not the build can run on a Raspberry Pi. Since the only reason we were not using this function before was to avoid building on a Pi, we no longer need the custom code. --- ci/Jenkinsfile | 74 +++------------------------------------------ ci/build.sh | 6 ---- ci/common.sh | 13 -------- ci/podTemplate.yaml | 19 ------------ ci/publish.sh | 15 --------- 5 files changed, 5 insertions(+), 122 deletions(-) delete mode 100644 ci/build.sh delete mode 100644 ci/common.sh delete mode 100644 ci/podTemplate.yaml delete mode 100644 ci/publish.sh diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index 2f9205b..a6c873d 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -1,70 +1,6 @@ -pipeline { - agent none +@Library('containerimages')_ - stages { - stage('Build') { - matrix { - axes { - axis { - name 'ARCH' - values 'amd64', 'arm64' - } - } - - stages { - stage('Build') { - agent { - kubernetes { - yamlFile 'ci/podTemplate.yaml' - yamlMergeStrategy merge() - defaultContainer 'buildah' - nodeSelector "kubernetes.io/arch=${ARCH}" - } - } - - stages { - stage("Build") { - steps { - sh '. ci/build.sh' - stash name: env.ARCH, includes: "*.oci.tar" - } - } - } - } - } - } - } - - stage('Publish') { - agent { - kubernetes { - yamlFile 'ci/podTemplate.yaml' - yamlMergeStrategy merge() - defaultContainer 'buildah' - } - } - - environment { - REGISTRY_AUTH_FILE = "${env.WORKSPACE_TMP}/auth.json" - } - - steps { - unstash 'amd64' - unstash 'arm64' - withCredentials([usernamePassword( - credentialsId: 'jenkins-packages', - usernameVariable: 'BUILDAH_USERNAME', - passwordVariable: 'BUILDAH_PASSWORD', - )]) { - sh """ - buildah login \ - --username \${BUILDAH_USERNAME} \ - --password \${BUILDAH_PASSWORD} \ - git.pyrocufflink.net - """ - } - sh '. ci/publish.sh' - } - } - } -} +buildContainerImage2( + archlist: ['amd64', 'arm64'], + pi: false, +) diff --git a/ci/build.sh b/ci/build.sh deleted file mode 100644 index 5e1315e..0000000 --- a/ci/build.sh +++ /dev/null @@ -1,6 +0,0 @@ -. ci/common.sh - -buildah build -t "${IMAGE_NAME}:${TAG}" . -buildah push \ - "${IMAGE_NAME}:${TAG}" \ - oci-archive:"${PWD}/${NAME}-${ARCH}.oci.tar:${IMAGE_NAME}:${TAG}" diff --git a/ci/common.sh b/ci/common.sh deleted file mode 100644 index 060e8cb..0000000 --- a/ci/common.sh +++ /dev/null @@ -1,13 +0,0 @@ -escape_name() { - echo "$1" \ - | tr A-Z a-z \ - | sed -e 's/[^a-zA-Z0-9._-]/-/g' -e 's/^[.-]/_/' -} - -REGISTRY_URL=git.pyrocufflink.net -NAMESPACE=containerimages -NAME="${JOB_NAME#*/}" -NAME=$(escape_name "${NAME%/*}") -TAG=$(escape_name "${BRANCH_NAME}") - -IMAGE_NAME="${REGISTRY_URL}/${NAMESPACE}/${NAME}" diff --git a/ci/podTemplate.yaml b/ci/podTemplate.yaml deleted file mode 100644 index 5da469f..0000000 --- a/ci/podTemplate.yaml +++ /dev/null @@ -1,19 +0,0 @@ -spec: - containers: - - name: buildah - image: quay.io/containers/buildah:v1 - command: - - cat - stdin: true - tty: true - securityContext: - capabilities: - add: - - SYS_ADMIN - - MKNOD - - SYS_CHROOT - - SETFCAP - resources: - limits: - github.com/fuse: 1 - hostUsers: false diff --git a/ci/publish.sh b/ci/publish.sh deleted file mode 100644 index 5e69dd7..0000000 --- a/ci/publish.sh +++ /dev/null @@ -1,15 +0,0 @@ -. ci/common.sh - -buildah manifest create "${IMAGE_NAME}:${TAG}" -for arch in amd64 arm64; do - buildah manifest add "${IMAGE_NAME}:${TAG}" \ - oci-archive:"${PWD}/${NAME}-${arch}.oci.tar:${IMAGE_NAME}:${TAG}" -done - -buildah manifest push --all "${IMAGE_NAME}:${TAG}" \ - "docker://${IMAGE_NAME}:${TAG}-${BUILD_NUMBER}" -buildah manifest push "${IMAGE_NAME}:${TAG}" "docker://${IMAGE_NAME}:${TAG}" -if [ ${BRANCH_NAME} = master ]; then - buildah manifest push "${IMAGE_NAME}:${TAG}" \ - "docker://${IMAGE_NAME}:latest" -fi