0

我在 Jenkins 和 Bazel 上看到了一个奇怪的权限问题。该构建使用我正在准备的基于 CentOS 的 docker 映像。

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

.bazelrc包含:

# 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

我想了解的是缺乏权限。该/home/jenkins文件夹是 Jenkins 用户的用户主目录。它在那里具有完整的读/写权限。

JAVA_HOME设置为 Azul OpenJDK 构建。已确认有效。

有什么想法我应该检查吗?

4

1 回答 1

0

我做了显而易见的事情,并将以下内容添加到Dockerfile创建构建容器的行中。

RUN chown -R jenkins:jenkins /home/jenkins
RUN chown -R jenkins:jenkins ${JAVA_HOME}

显然,某些权限不适用于默认设置。现在我通过了这个问题。

于 2021-11-11T12:18:12.987 回答