Add --branch to build images for a specific Gerrit branch Introduce a new `--branch` option to the `build` script, enabling images to be built against a Gerrit branch other than `master`. The branch is forwarded to Docker as `--build-arg GERRIT_BRANCH=<branch>` and defaults to `master` when not provided. This makes it easier to build and deploy stable branches. Bug: Issue 455813734 Change-Id: I0b3017519bfed4b62b27c89cbdbebdc68f5321e7
diff --git a/README.md b/README.md index 0eac1a6..4f572ad 100644 --- a/README.md +++ b/README.md
@@ -49,6 +49,15 @@ ./build --gerrit-url https://example.com/gerrit.war ``` +The version of plugins and modules built into the images can be changed by providing +the Gerrit branch. By default, the branch is set to `master`: +``` +./build --branch stable-3.13 +``` + +Note, if you do not include the `--gerrit-url` option, the image will automatically use +the Gerrit release that corresponds to the selected `--branch`. + The version of a health-check plugin built into the images can be changed by providing a download URL for a `.jar`-file containing the plugin:
diff --git a/build b/build index 4458f1f..9202147 100755 --- a/build +++ b/build
@@ -16,7 +16,7 @@ usage() { me=`basename "$0"` - echo >&2 "Usage: $me [--help] [--tag TAG] [--no-cache] [--gerrit-url URL] [--base-image IMAGE] [--platform PLATFORM] [IMAGE]" + echo >&2 "Usage: $me [--help] [--tag TAG] [--no-cache] [--gerrit-url URL] [--base-image IMAGE] [--platform PLATFORM] [--branch GERRIT_BRANCH] [IMAGE]" exit 1 } @@ -61,6 +61,12 @@ shift ;; + --branch) + shift + GERRIT_BRANCH=$1 + shift + ;; + *) break esac @@ -71,6 +77,7 @@ IMAGES=$(get_image_list) PLATFORM=${PLATFORM:-linux/amd64} # Default value if PLATFORM is not set +GERRIT_BRANCH=${GERRIT_BRANCH:-master} # Default value if GERRIT_BRANCH is not set DOCKER_BUILD_OPTS="--platform=$PLATFORM" test -n "$NO_CACHE" && DOCKER_BUILD_OPTS="$DOCKER_BUILD_OPTS --no-cache" @@ -103,7 +110,7 @@ } docker_build_gerrit_base(){ - BUILD_ARGS="$BUILD_ARGS --build-arg TAG=$REV" + BUILD_ARGS="$BUILD_ARGS --build-arg TAG=$REV --build-arg GERRIT_BRANCH=$GERRIT_BRANCH" docker build \ $DOCKER_BUILD_OPTS \ $BUILD_ARGS \