Gitlab-runner maven 构建失败,并显示“权限被拒绝”消息,但在调试选项打开时成功

问题描述 投票:0回答:1

我正在尝试使用 gitlab-runner 使用 Maven 映像构建 java 项目。 直到昨天我遇到以下错误时才出现问题 权限被拒绝。

这是我运行的命令,

mvn clean install -P prd -Dmaven.test.skip=true

但是一旦我在命令中添加 -X 选项,构建就会突然开始工作。 调试模式到底与用户的权限有什么关系?

因为我对编程还很陌生,所以我对构建的工作原理几乎为零 但这个问题似乎是闻所未闻的。

有人可以对此发表见解吗?

谢谢你。

[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ gra-api ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2594 source files to /home/gitlab-runner/builds/CsiK6vc5/0/p202008_0045_gra/graapi/graapi/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.536 s
[INFO] Finished at: 2023-12-06T21:23:20+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project gra-api: Fatal error compiling: Error creating file with javac arguments: Permission denied -> [Help 1]
[ERROR] 

我改变了maven编译器版本但没有用, 检查了 gitlab-runner 帐户的权限,没有问题, 尝试在运行命令时使用 sudo,但这也不起作用。

maven maven-plugin gitlab-ci-runner javac
1个回答
0
投票

显然maven正在将文件写入/tmp文件夹, 我不知道细节,如果有人能详细说明一下就好了。

但是由于 /tmp 文件夹属于 root,因此 gitlab-runner 无权向该文件夹写入文件,

我已经更改了所有用户的写入权限,并且不再出现错误。

从以下问题中得到答案!

使用 mvn cobertura 插件时权限被拒绝

© www.soinside.com 2019 - 2024. All rights reserved.