jenkinspipeline无法构建springboot应用程序
`+ mvn -f EquipOptimizationApi/AddNewEquipment/pom.xml install ----- withMaven Wrapper script ----- Picked up JAVA_TOOL_OPTIONS: -Dmaven.ext.class.path="/var/lib/jenkins/workspace/addNewEquip@tmp/withMaven2d5b8b4d/pipeline-maven-spy.jar"
-Dorg.jenkinsci.plugins.pipeline.maven.reportsFolder =“ / var / lib / jenkins / workspace / addNewEquip @ tmp / withMaven2d5b8b4d”
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T18:33:14Z) Maven home: /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven Java version: 1.8.0_171, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.amzn2.x86_64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "4.14.47-64.38.amzn2.x86_64", arch: "amd64", family: "unix" [INFO] [jenkins-event-spy] Generate /var/lib/jenkins/workspace/addNewEquip@tmp/withMaven2d5b8b4d/maven-spy-20180718-135754-559519187898694815320.log.tmp
... [INFO]正在扫描项目... [信息] [INFO] ----------------------
------------------ ---- [INFO]建立AddNewEquipment 0.0.1-SNAPSHOT [INFO] -------------------------------- [jar] ------------ --------------------- [信息] [INFO] --- maven-resources-plugin:2.6:resources(default-resources)@ AddNewEquipment --- [INFO]使用'UTF-8'编码复制过滤的资源。 [INFO]正在复制0个资源 [INFO]复制5个资源 [信息] [INFO] --- maven-compiler-plugin:3.1:compile(default-compile)@ AddNewEquipment --- [INFO]检测到更改-重新编译模块! [INFO]将13个源文件编译到/ var / lib / jenkins / workspace / addNewEquip / EquipOptimizationApi / AddNewEquipment / target / classes [INFO] ----------------------------------------------- -------------- [ERROR]编译错误: [INFO] ----------------------------------------------- -------------- [错误]在此环境中未提供编译器。也许您是在JRE而不是JDK上运行? [INFO] 1个错误 [INFO] ----------------------------------------------- -------------- [INFO] ----------------------------------------------- ------------------------- [INFO]建立失败 [INFO] ----------------------------------------------- ------------------------- [INFO]总时间:2.893秒 [INFO]完成于:2018-07-18T13:57:57Z [INFO] ----------------------------------------------- ------------------------- [INFO] [jenkins-event-spy]生成的/var/lib/jenkins/workspace/addNewEquip@tmp/withMaven2d5b8b4d/maven-spy-20180718-135754-559519187898694815320.log [错误]无法执行目标org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (默认编译)在项目AddNewEquipment上:编译失败 [错误]在此环境中未提供编译器。也许您是在JRE而不是JDK上运行? [错误]-> [帮助1] [错误] [错误]要查看错误的完整堆栈跟踪,请使用-e开关重新运行Maven。 [错误]使用-X开关重新运行Maven以启用完整的调试日志记录。 [错误] [ERROR]有关错误和可能的解决方案的详细信息,请阅读以下文章: [错误] [帮助1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException [管道]} [withMaven]找不到Jenkins Task Scanner插件,不显示源代码中“ TODO”和“ FIXME”的扫描结果 管道屏幕。 [管道] // withMaven [管道]} [管道] //舞台 [管道]} [管道] // withEnv [管道]} [管道] //节点 [管道]管道末端 错误:脚本返回了退出代码1 完成:失败`
答案 0 :(得分:0)
在管道中,您必须声明jdk。
您必须在全局工具管理中配置工具jdk。
示例:
pipeline {
tools {
jdk 'openjdk-1.8'
maven 'Maven_3_5_2'
}
stages {
stage('Build') {
steps {
echo 'Building..'
sh "mvn clean install"
}
}
}
}
您还可以修改节点的JAVA_HOME本地设置。
node {
jdk = tool name: 'JDK17'
env.JAVA_HOME = "${jdk}"
echo "jdk installation path is: ${jdk}"
// next 2 are equivalents
sh "${jdk}/bin/java -version"
// note that simple quote strings are not evaluated by Groovy
// substitution is done by shell script using environment
sh '$JAVA_HOME/bin/java -version'
}