From: Zack Cerza Date: Mon, 21 Apr 2025 17:52:38 +0000 (-0600) Subject: ceph-dev-pipeline: Build the builder less often X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=897952bef8f3b6fff847f9f9d265a81fc9e04729;p=ceph-build.git ceph-dev-pipeline: Build the builder less often 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 --- diff --git a/ceph-dev-pipeline/build/Jenkinsfile b/ceph-dev-pipeline/build/Jenkinsfile index 1f6d373a..fa70a6ef 100644 --- a/ceph-dev-pipeline/build/Jenkinsfile +++ b/ceph-dev-pipeline/build/Jenkinsfile @@ -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" ) {