gerrit: get files from bazel build dir

bazel likes to build everything in ~/.cache and then symlink bazel-*
"convience symlinks" in the workspace/build directory.  This causes a
problem for building docker images where we run in the context of the
build directory; docker will not follow the symlinks out of build

Currently the bazelisk-build copies parts of the build to the
top-level; this means the bazelisk-build role is gerrit specific,
rather than generic as the name implies.

We modify the gerrit build step to break build output symlink and move
it into the top level of the build tree, which is the context the
docker build runs in later.  Since this is now just a normal
directory, we can copy from it at will there.

This is useful in follow-on builds where we want to start copying more
than just the release.war file from the build tree, e.g. polygerrit
plugin output.

While we're here, remove the javamelody things that were only for 2.X
series gerrit, which we don't build any more.


Change-Id: I00abe437925d805bd88824d653eec38fa95e4fcd
Ian Wienand 2 years ago committed by Clark Boylan
parent e80893eb3d
commit 951c2f4cde

@ -17,15 +17,10 @@
FROM as gerrit
COPY release.war /var/gerrit/bin/gerrit.war
COPY bazel-bin/release.war /var/gerrit/bin/gerrit.war
# Install plugins
RUN mkdir /var/gerrit/plugins && \
unzip -jo /var/gerrit/bin/gerrit.war WEB-INF/plugins/* -d /var/gerrit/plugins
COPY opendevtheme.html /var/gerrit/plugins/opendevtheme.html
FROM gerrit as gerrit-2
# Only Gerrit 2.14, 2.15, and 2.16 need this COPY
COPY javamelody-deps_deploy.jar /var/gerrit/lib/javamelody-deps_deploy.jar

@ -12,6 +12,28 @@
zuul_work_dir: /home/zuul/src/
# Bazel makes "convenience symlinks" [1] starting with bazel-* to
# the actual build output. The problem is that we want to use the
# source tree as the context/build dir for our Docker container,
# and Docker refuses to follow symlinks for COPY commands; i.e. we
# can't copy stuff from the build output into the container.
# Therefore break the bazel-bin link and move to the top level so
# we can copy the built bits (jars, plugins, etc) into the
# container easily.
# [1]
- name: Make bazel-bin docker friendly
cmd: |
if [ ! -L bazel-bin ]; then
echo "bazel-bin not a symlink?"
exit 1
target=$(readlink bazel-bin)
rm bazel-bin
mv $target bazel-bin
chdir: /home/zuul/src/
- name: Install OpenDev theme plugin
src: opendevtheme.html

@ -3,13 +3,11 @@
set -x
java -fullversion
{{ bazelisk_executable }} version
{{ bazelisk_executable }} build --spawn_strategy=standalone --genrule_strategy=standalone {{ bazelisk_targets|join(' ') }}
if [[ -f bazel-bin/plugins/javamelody/javamelody-deps_deploy.jar ]] ; then
# versions 2.14, 2.15, and 2.16 generate this file
cp bazel-bin/plugins/javamelody/javamelody-deps_deploy.jar javamelody-deps_deploy.jar
# release.war is a symlink. We want an actual file so that docker copy works right.
cp bazel-bin/release.war release.war
{{ bazelisk_executable }} \
build \
--spawn_strategy=standalone \
--genrule_strategy=standalone \
{{ bazelisk_targets|join(' ') }}
executable: /bin/bash
chdir: "{{ zuul_work_dir }}"