I'm seeing a weird permission issue on Jenkins with Bazel. The build is using a CentOS based docker image that I am preparing.
21:56:37 + bazel build //src/main/java:HelloWorld
21:56:42 2021/11/10 20:56:42 Downloading https://releases.bazel.build/4.2.1/release/bazel-4.2.1-linux-x86_64...
21:56:48 Extracting Bazel installation...
21:56:49 Starting local Bazel server and connecting to it...
21:56:51 Loading:
21:56:51 Loading: 0 packages loaded
21:56:51 Loading: 0 packages loaded
21:56:53 Loading: 0 packages loaded
21:56:53 Analyzing: target //src/main/java:HelloWorld (1 packages loaded, 0 targets configured)
21:56:55 Analyzing: target //src/main/java:HelloWorld (10 packages loaded, 18 targets configured)
21:56:55 Analyzing: target //src/main/java:HelloWorld (21 packages loaded, 285 targets configured)
21:56:57 Analyzing: target //src/main/java:HelloWorld (21 packages loaded, 285 targets configured)
21:56:58 Analyzing: target //src/main/java:HelloWorld (21 packages loaded, 285 targets configured)
21:56:59 Analyzing: target //src/main/java:HelloWorld (22 packages loaded, 322 targets configured)
21:57:02 Analyzing: target //src/main/java:HelloWorld (22 packages loaded, 322 targets configured)
21:57:02 INFO: Analyzed target //src/main/java:HelloWorld (23 packages loaded, 454 targets configured).
21:57:02 INFO: Found 1 target...
21:57:03 [0 / 4] [Prepa] BazelWorkspaceStatusAction stable-status.txt
21:57:05 ERROR: /home/jenkins/.cache/bazel/_bazel_jenkins/61c828dc7f69c1411a6e2ba3a115033a/external/bazel_tools/tools/jdk/BUILD:346:14: Action external/bazel_tools/tools/jdk/platformclasspath.jar failed: missing input file 'external/local_jdk/lib/jfr/MethodAndContention.jfc', owner: '@local_jdk//:lib/jfr/MethodAndContention.jfc': /home/jenkins/.cache/bazel/_bazel_jenkins/61c828dc7f69c1411a6e2ba3a115033a/external/local_jdk/lib/jfr/MethodAndContention.jfc (Permission denied)
21:57:05 Target //src/main/java:HelloWorld failed to build
21:57:05 Use --verbose_failures to see the command lines of failed build steps.
21:57:05 ERROR: /home/jenkins/.cache/bazel/_bazel_jenkins/61c828dc7f69c1411a6e2ba3a115033a/external/bazel_tools/tools/jdk/BUILD:346:14 Action external/bazel_tools/tools/jdk/platformclasspath.jar failed: 1 input file(s) do not exist
21:57:05 INFO: Elapsed time: 18.036s, Critical Path: 1.11s
21:57:05 INFO: 2 processes: 1 internal, 1 linux-sandbox.
21:57:05 FAILED: Build did NOT complete successfully
21:57:05 FAILED: Build did NOT complete successfully
The .bazelrc
contains:
# use the JDK available in Jennkins for everything
build --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
build --java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
What I'm trying to understand is the lack of permissions. The /home/jenkins
folder is the user home directory of the Jenkins user. It has full read/write permissions there.
JAVA_HOME
is set to an Azul OpenJDK build. It's confirmed to work.
Any ideas what I should check?
I did the obvious and added the following to lines to the Dockerfile
creating the build container.
RUN chown -R jenkins:jenkins /home/jenkins
RUN chown -R jenkins:jenkins ${JAVA_HOME}
Obviously some permissions aren't ok with the default setup. Now I get passed the issue.