Skip to content

Commit

Permalink
Propagate $BAZEL_OPTS to all implicit build commands
Browse files Browse the repository at this point in the history
Bazel expects the cache to be remote for all executions of the
initial build of Gerrit, because of [1].
Failing to set the remote cache server URL would result in
a file transfer failure and therefore the failure of the whole
build.

Adding the "build $BAZEL_OPTS" in the user.bazelrc resolves
the problem.

Also add the explicit fetch of the PolyGerrit NPM repositories
which aren't automatically fetched when the workspace is refreshed
from the remote Git repository. This is mandatory for preventing
the build to fail when using the local disk cache,

[1] bazelbuild/bazel#20161

Bug: Issue 316936462
Change-Id: I4cd6b4167c4025fe05d852d16f7cea5042046787
  • Loading branch information
lucamilanesio committed Dec 28, 2023
1 parent 5df7801 commit 076389e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
17 changes: 16 additions & 1 deletion jenkins/gerrit-bazel-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ echo '----------------------------------------------'
java -fullversion
bazelisk version

# Whilst all the rest of Gerrit is able to automatically sync the Bazel repositories
# the PolyGerrit part fails to do so when the working directory is replaced with a
# fresh clone from the remote Git repository
bazelisk sync --only=npm --only=tools_npm --only=ui_npm --only=plugins_npm

if [[ "$MODE" == *"rbe"* ]]
then
# TODO(davido): Figure out why javadoc part of api-rule doesn't work on RBE.
Expand All @@ -32,7 +37,17 @@ elif [[ "$MODE" == *"polygerrit"* ]]
then
echo "Skipping building eclipse and maven"
else
bazelisk build $BAZEL_OPTS plugins:core release api
# This is a workaround to Issue 316936462: after the initial build with $BAZEL_OPTS
# that include a remote cache, the subsequent implicit build commands executed would
# expect the cache to be remote and fail to download the artifact if the $BAZEL_OPTS
# are not passed. Because the 'bazel build' commands are dynamically generated, the
# only way to pass the extra parameters is via user.bazelrc
if [[ "$BAZEL_OPTS" != "" ]]
then
echo "build $BAZEL_OPTS" >> user.bazelrc
fi

bazelisk build plugins:core release api
tools/maven/api.sh install
tools/eclipse/project.py --bazel bazelisk
fi
18 changes: 17 additions & 1 deletion jenkins/gerrit-mvn-build-plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,23 @@ git checkout -f -b gerrit-master gerrit/{branch}
git submodule update --init
java -fullversion
bazelisk version
bazelisk build $BAZEL_OPTS api

# This is a workaround to Issue 316936462: after the initial build with $BAZEL_OPTS
# that include a remote cache, the subsequent implicit build commands executed would
# expect the cache to be remote and fail to download the artifact if the $BAZEL_OPTS
# are not passed. Because the 'bazel build' commands are dynamically generated, the
# only way to pass the extra parameters is via .bazelrc
if [[ "$BAZEL_OPTS" != "" ]]
then
echo "build $BAZEL_OPTS" >> .bazelrc
fi

# Whilst all the rest of Gerrit is able to automatically sync the Bazel repositories
# the PolyGerrit part fails to do so when the working directory is replaced with a
# fresh clone from the remote Git repository
bazelisk sync --only=npm --only=tools_npm --only=ui_npm --only=plugins_npm

bazelisk build api
./tools/maven/api.sh install

git checkout -f origin/{branch}
Expand Down

0 comments on commit 076389e

Please sign in to comment.