From: John Mulligan Date: Fri, 14 Feb 2025 16:37:04 +0000 (-0500) Subject: script/build-with-container: add --base-branch cli option X-Git-Tag: v18.2.5~23^2~7 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=8a3e3af0fa31fa507051d8b3b2812e67c937318c;p=ceph-ci.git script/build-with-container: add --base-branch cli option Add a command line option --base-branch that allows the user to supply a custom base branch name. git doesn't make determining this easy so we always assume a base branch of 'main' by default - but this option lets one change that. Signed-off-by: John Mulligan (cherry picked from commit ff34bf7241f1a1072f74494cc8f50156e0076019) --- diff --git a/src/script/build-with-container.py b/src/script/build-with-container.py index 7b199eb42e6..d7ec7c0ad12 100755 --- a/src/script/build-with-container.py +++ b/src/script/build-with-container.py @@ -294,6 +294,15 @@ class Context: branch = "UNKNOWN" return f"{branch}.{self.cli.distro}" + def base_branch(self): + # because git truly is the *stupid* content tracker there's not a + # simple way to detect base branch. In BWC the base branch is really + # only here for an optional 2nd level of customization in the build + # container bootstrap we default to `main` even when that's not true. + # One can explicltly set the base branch on the command line to invoke + # customizations (that don't yet exist) or invalidate image caching. + return self.cli.base_branch or 'main' + @property def from_image(self): if self.cli.base_image: @@ -401,6 +410,7 @@ def build_container(ctx): "-t", ctx.image_name, f"--build-arg=JENKINS_HOME={ctx.cli.homedir}", + f"--build-arg=CEPH_BASE_BRANCH={ctx.base_branch()}", ] if ctx.cli.distro: cmd.append(f"--build-arg=DISTRO={ctx.from_image}") @@ -670,6 +680,10 @@ def parse_cli(build_step_names): "-t", help="Specify a container tag", ) + parser.add_argument( + "--base-branch", + help="Specify a base branch name", + ) parser.add_argument( "--current-branch", help="Manually specify the current branch name",