我使用Gradle使用shell脚本生成战争文件,但我得到以下错误。
ls
cd ClaimCenter1003
javac -version
chmod 777 gwb.sh
./gwb.sh warTomcatDbcp
05-Jun-2020 13:22:54 ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
05-Jun-2020 13:22:54
05-Jun-2020 13:22:54 Please set the JAVA_HOME variable in your environment to match the
05-Jun-2020 13:22:54 location of your Java installation.
所有的竹子服务器都设置了Java,虽然在很多服务器上没有通过控制台工作,但是当我通过命令行触发构建时,它工作正常。
在一些服务器中,构建工作能够给我提供我需要的输出。
javac 1.8.0_161
build 05-Jun-2020 13:18:01 Downloading file:/opt/bamboo-agent-home/xml-data/build-dir/GUID-GCCA-VAR/ClaimCenter1003/gradle/wrapper/./gradle.zip
build 05-Jun-2020 13:18:02 .................................................................................
build 05-Jun-2020 13:18:04
build 05-Jun-2020 13:18:04 Welcome to Gradle 5.1.1!
build 05-Jun-2020 13:18:04
build 05-Jun-2020 13:18:04 Here are the highlights of this release:
build 05-Jun-2020 13:18:04 - Control which dependencies can be retrieved from which repositories
build 05-Jun-2020 13:18:04 - Production-ready configuration avoidance APIs
构建过程中,当我在CLI中做了
请帮我解决这个问题。谢谢你的帮助
无论是JAVA_HOME还是PATH都没有被设置为失败的构建代理。
如果我是你的情况,我会首先采取措施确保这些设置存在。
一个简单的方法是通过简单的使用docker来 "docker化 "你的构建,例如:。docker run openjdk:{JDK_VERSION} bash `./buildscript.sh`
.
另一种方法是在开始实际构建步骤之前,确保java正确安装在你的构建代理上。问题是,你的构建代理实例似乎会被其他构建重用,所以即使这样做有效,也可能会导致下游的其他错误,因此我建议通过docker虚拟化你的构建。
我会检查$JAVA和$JAVA_HOME是否设置正确,如果不正确,要么显式安装java(例如参见 https:/docs.aws.amazon.comcorrettolatestcorretto-8-uggeneric-linux-install.html。 到安装amazon coretto openjdk的步骤,或者如果你确定java存在于目标机器上,可以手动设置环境变量。