gpt4 book ai didi

linux - 如何使 "./gradlew"与 "sudo ./gradlew"相同?

转载 作者:太空宇宙 更新时间:2023-11-04 12:52:25 24 4
gpt4 key购买 nike

我正在 salve 机器上设置 Jenkins 作业,我是 Linux shell 的新手。现在我有一个问题:

以 jenkins(为 Jenkins 作业设置的用户帐户)登录,执行 ./gradlew,然后开始下载 https://downloads.gradle.org/distributions/gradle-2.10-bin.zip ,它会因为网络不好而失败,而如果它执行“sudo ./gradlew”,它将开始正常运行 gradle。

有人可以帮助并告诉我,如何使“./gradlew”与用户 jenkins 的“sudo ./gradlew”相同吗?

所有的 shell 脚本都来自 git,所以我不能通过添加“sudo”来修改它。

在我的真实工作场景中添加日志:

jenkins@reed:/local/jenkins/workspace/SV_TEST_/automation/robot$ id
uid=180(jenkins) gid=0(root) group=0(root)

jenkins@reed:/local/jenkins/workspace/SV_TEST_/automation/robot$ sudo ./gradlew webAPI:compileJava
Starting a new Gradle Daemon for this build (subsequent builds will be faster).
:common:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.7
:common:processResources UP-TO-DATE
:common:classes
:common:jar
:webAPI:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.7

BUILD SUCCESSFUL

Total time: 10.204 secs
jenkins@reed:/local/jenkins/workspace/SV_TEST_/automation/robot$ /local/jenkins/workspace/SV_TEST/automation/robot/gradlew -g /local/jenkins/.gradle -p /local/jenkins/workspace/SV_TEST/automation/robot clean
Downloading https://services.gradle.org/distributions/gradle-2.10-bin.zip
...

最佳答案

尝试将 gradlew 中的最后一行替换为以下内容:

exec sudo "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH"  org.gradle.wrapper.GradleWrapperMain "$@"

关于linux - 如何使 "./gradlew"与 "sudo ./gradlew"相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36763441/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com