]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-build.git/commitdiff
ceph-dev-pipeline: Build the builder less often
authorZack Cerza <zack@cerza.org>
Mon, 21 Apr 2025 17:52:38 +0000 (11:52 -0600)
committerZack Cerza <zack@cerza.org>
Wed, 7 May 2025 23:28:45 +0000 (17:28 -0600)
To build the builder image less often, we can:

1. When building, use two tags: branch.os.arch, and sha1.branch.os.arch
2. After building, push both tags
3. Before building, pull both tags

As a result, we can avoid building entirely if that exact image has already been
pushed, and avoid building at least some layers if the branch had been built
somewhat recently.

Signed-off-by: Zack Cerza <zack@cerza.org>
ceph-dev-pipeline/build/Jenkinsfile

index 1f6d373acfd9a145f5ac9094b920ec48813f34d2..fa70a6ef19e01a1005134c173a45a17e0ae67d2d 100644 (file)
@@ -311,17 +311,26 @@ pipeline {
             steps {
               script {
                 env.CEPH_BUILDER_IMAGE = "${env.CONTAINER_REPO_HOSTNAME}/${env.CONTAINER_REPO_ORGANIZATION}/ceph-build"
-                def ceph_builder_tag = "${env.BRANCH}.${env.DIST}.${ARCH}"
                 sh '''#!/bin/bash
                   set -ex
                   podman login -u ${CONTAINER_REPO_CREDS_USR} -p ${CONTAINER_REPO_CREDS_PSW} ${CONTAINER_REPO_HOSTNAME}/${CONTAINER_REPO_ORGANIZATION}
                   podman login -u ${DOCKER_HUB_CREDS_USR} -p ${DOCKER_HUB_CREDS_PSW} docker.io
                 '''
-                def os = get_os_info(env.DIST)
+                def ceph_builder_tag_short = "${env.BRANCH}.${env.DIST}.${ARCH}"
+                def ceph_builder_tag = "${env.SHA1[0..6]}.${ceph_builder_tag_short}"
+                sh """#!/bin/bash -ex
+                  podman pull ${env.CEPH_BUILDER_IMAGE}:${ceph_builder_tag} || \
+                  podman pull ${env.CEPH_BUILDER_IMAGE}:${ceph_builder_tag_short} || \
+                  true
+                """
                 sh """#!/bin/bash
                   set -ex
                   cd dist/ceph
                   python3 src/script/build-with-container.py --image-repo=${env.CEPH_BUILDER_IMAGE} --tag=${ceph_builder_tag} -d ${DIST} -e build-container
+                  podman tag ${env.CEPH_BUILDER_IMAGE}:${ceph_builder_tag} ${env.CEPH_BUILDER_IMAGE}:${ceph_builder_tag_short}
+                """
+                sh """#!/bin/bash -ex
+                  podman push ${env.CEPH_BUILDER_IMAGE}:${ceph_builder_tag_short}
                   podman push ${env.CEPH_BUILDER_IMAGE}:${ceph_builder_tag}
                 """
               }
@@ -372,7 +381,7 @@ pipeline {
                   )
                   bwc_cmd_sccache_flags = "--env-file=${env.WORKSPACE}/.env";
                 }
-                def ceph_builder_tag = "${env.BRANCH}.${env.DIST}.${ARCH}"
+                def ceph_builder_tag = "${env.SHA1[0..6]}.${env.BRANCH}.${env.DIST}.${ARCH}"
                 def bwc_command_base = "python3 src/script/build-with-container.py ${bwc_cmd_sccache_flags} --image-repo=${env.CEPH_BUILDER_IMAGE} --tag=${ceph_builder_tag} -d ${DIST} --ceph-version ${env.VERSION}"
                 def bwc_command = bwc_command_base
                 if ( os.pkg_type == "deb" ) {