当前位置:   article > 正文

win10系统下的jenkins,部署代码到阿里云服务器centos7,jenkins报错说maven插件不兼容和java路径找不到的情况可以参照这个博客。如果是找不到java路径,那么你就用最后面的_jenkins2.346加载maven插件报版本不兼容问题

jenkins2.346加载maven插件报版本不兼容问题

win10系统下的jenkins,部署代码到阿里云服务器centos7报错:

  1. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project order: Fatal error compiling: tools.jar not found: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/../lib/tools.jar -> [Help 1]
  2. [ERROR]
  3. [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  4. [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  5. [ERROR]
  6. [ERROR] For more information about the errors and possible solutions, please read the following articles:
  7. [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
  8. tomcat Id list :1723
  9. cp: cannot stat ‘/root/.jenkins/workspace/DeployOrder/order/target/order.war’: No such file or directory
  10. mv: cannot stat ‘order.war’: No such file or directory
  11. Tomcat started.
  12. Finished: SUCCESS

报错全文:

  1. Started by user admin
  2. Running as SYSTEM
  3. Building remotely on Aliyun_server_centos7.3 in workspace /root/.jenkins/workspace/DeployOrder
  4. No credentials specified
  5. > /usr/local/bin/git rev-parse --is-inside-work-tree # timeout=10
  6. Fetching changes from the remote Git repository
  7. > /usr/local/bin/git config remote.origin.url git@github.com:fushaoleigithub/order.git # timeout=10
  8. Fetching upstream changes from git@github.com:fushaoleigithub/order.git
  9. > /usr/local/bin/git --version # timeout=10
  10. > /usr/local/bin/git fetch --tags --force --progress -- git@github.com:fushaoleigithub/order.git +refs/heads/*:refs/remotes/origin/* # timeout=10
  11. > /usr/local/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
  12. > /usr/local/bin/git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
  13. Checking out Revision 4cc9b0d597b98877cf2ac78a78043e915ea2df61 (refs/remotes/origin/master)
  14. > /usr/local/bin/git config core.sparsecheckout # timeout=10
  15. > /usr/local/bin/git checkout -f 4cc9b0d597b98877cf2ac78a78043e915ea2df61 # timeout=10
  16. Commit message: "update mysql configuration"
  17. > /usr/local/bin/git rev-list --no-walk 4cc9b0d597b98877cf2ac78a78043e915ea2df61 # timeout=10
  18. [DeployOrder] $ /bin/sh -xe /tmp/jenkins7553308970146550982.sh
  19. + BUILD_ID=DONTKILLME
  20. + . /etc/profile
  21. ++ '[' -x /usr/bin/id ']'
  22. ++ '[' -z 0 ']'
  23. +++ /usr/bin/id -un
  24. ++ USER=root
  25. ++ LOGNAME=root
  26. ++ MAIL=/var/spool/mail/root
  27. ++ '[' 0 = 0 ']'
  28. ++ pathmunge /usr/sbin
  29. ++ case ":${PATH}:" in
  30. ++ pathmunge /usr/local/sbin
  31. ++ case ":${PATH}:" in
  32. +++ /usr/bin/hostname
  33. ++ HOSTNAME=iz8vb4rhbik3h93v48ztfvz
  34. ++ HISTSIZE=1000
  35. ++ '[' '' = ignorespace ']'
  36. ++ export HISTCONTROL=ignoredups
  37. ++ HISTCONTROL=ignoredups
  38. ++ export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
  39. ++ '[' 0 -gt 199 ']'
  40. ++ umask 022
  41. ++ for i in '/etc/profile.d/*.sh' /etc/profile.d/sh.local
  42. ++ '[' -r /etc/profile.d/256term.sh ']'
  43. ++ '[' ehxB '!=' ehxB ']'
  44. ++ . /etc/profile.d/256term.sh
  45. +++ local256=
  46. +++ '[' -n '' ']'
  47. +++ '[' -n '' ']'
  48. +++ unset local256
  49. ++ for i in '/etc/profile.d/*.sh' /etc/profile.d/sh.local
  50. ++ '[' -r /etc/profile.d/colorgrep.sh ']'
  51. ++ '[' ehxB '!=' ehxB ']'
  52. ++ . /etc/profile.d/colorgrep.sh
  53. +++ /usr/libexec/grepconf.sh -c
  54. +++ alias 'grep=grep --color=auto'
  55. +++ alias 'egrep=egrep --color=auto'
  56. +++ alias 'fgrep=fgrep --color=auto'
  57. ++ for i in '/etc/profile.d/*.sh' /etc/profile.d/sh.local
  58. ++ '[' -r /etc/profile.d/colorls.sh ']'
  59. ++ '[' ehxB '!=' ehxB ']'
  60. ++ . /etc/profile.d/colorls.sh
  61. +++ '[' '!' -t 0 ']'
  62. +++ return
  63. ++ for i in '/etc/profile.d/*.sh' /etc/profile.d/sh.local
  64. ++ '[' -r /etc/profile.d/lang.sh ']'
  65. ++ '[' ehxB '!=' ehxB ']'
  66. ++ . /etc/profile.d/lang.sh
  67. +++ sourced=0
  68. +++ '[' -n en_US.UTF-8 ']'
  69. +++ saved_lang=en_US.UTF-8
  70. +++ '[' -f /root/.i18n ']'
  71. +++ LANG=en_US.UTF-8
  72. +++ unset saved_lang
  73. +++ '[' 0 = 1 ']'
  74. +++ unset sourced
  75. +++ unset langfile
  76. ++ for i in '/etc/profile.d/*.sh' /etc/profile.d/sh.local
  77. ++ '[' -r /etc/profile.d/less.sh ']'
  78. ++ '[' ehxB '!=' ehxB ']'
  79. ++ . /etc/profile.d/less.sh
  80. +++ '[' -x /usr/bin/lesspipe.sh ']'
  81. +++ export 'LESSOPEN=||/usr/bin/lesspipe.sh %s'
  82. +++ LESSOPEN='||/usr/bin/lesspipe.sh %s'
  83. ++ for i in '/etc/profile.d/*.sh' /etc/profile.d/sh.local
  84. ++ '[' -r /etc/profile.d/vim.sh ']'
  85. ++ '[' ehxB '!=' ehxB ']'
  86. ++ . /etc/profile.d/vim.sh
  87. +++ '[' -n '4.2.46(2)-release' -o -n '' -o -n '' ']'
  88. +++ '[' -x /usr/bin/id ']'
  89. ++++ /usr/bin/id -u
  90. +++ ID=0
  91. +++ '[' -n 0 -a 0 -le 200 ']'
  92. +++ return
  93. ++ for i in '/etc/profile.d/*.sh' /etc/profile.d/sh.local
  94. ++ '[' -r /etc/profile.d/which2.sh ']'
  95. ++ '[' ehxB '!=' ehxB ']'
  96. ++ . /etc/profile.d/which2.sh
  97. +++ alias 'which=alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
  98. ++ for i in '/etc/profile.d/*.sh' /etc/profile.d/sh.local
  99. ++ '[' -r /etc/profile.d/sh.local ']'
  100. ++ '[' ehxB '!=' ehxB ']'
  101. ++ . /etc/profile.d/sh.local
  102. ++ unset i
  103. ++ unset -f pathmunge
  104. ++ export MAVEN_HOME=/root/apache-maven-3.6.3
  105. ++ MAVEN_HOME=/root/apache-maven-3.6.3
  106. ++ export PATH=/root/apache-maven-3.6.3/bin:/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
  107. ++ PATH=/root/apache-maven-3.6.3/bin:/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
  108. ++ pwd
  109. + export PROJ_PATH=/root/.jenkins/workspace/DeployOrder
  110. + PROJ_PATH=/root/.jenkins/workspace/DeployOrder
  111. + export TOMCAT_APP_PATH=/root/apache-tomcat-9.0.34
  112. + TOMCAT_APP_PATH=/root/apache-tomcat-9.0.34
  113. + sh /root/.jenkins/workspace/DeployOrder/order/deploy.sh
  114. [INFO] Scanning for projects...
  115. [WARNING]
  116. [WARNING] Some problems were encountered while building the effective model for com.lesson:order:war:1.0
  117. [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-war-plugin is missing. @ line 96, column 12
  118. [WARNING]
  119. [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
  120. [WARNING]
  121. [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
  122. [WARNING]
  123. [INFO]
  124. [INFO] --------------------------< com.lesson:order >--------------------------
  125. [INFO] Building order 1.0
  126. [INFO] --------------------------------[ war ]---------------------------------
  127. [INFO]
  128. [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ order ---
  129. [INFO] Deleting /root/.jenkins/workspace/DeployOrder/order/target
  130. [INFO]
  131. [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ order ---
  132. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  133. [INFO] Copying 2 resources
  134. [INFO]
  135. [INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ order ---
  136. [INFO] Compiling 9 source files to /root/.jenkins/workspace/DeployOrder/order/target/classes
  137. [INFO] ------------------------------------------------------------------------
  138. [INFO] BUILD FAILURE
  139. [INFO] ------------------------------------------------------------------------
  140. [INFO] Total time: 0.709 s
  141. [INFO] Finished at: 2020-04-17T12:13:16+08:00
  142. [INFO] ------------------------------------------------------------------------
  143. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project order: Fatal error compiling: tools.jar not found: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/../lib/tools.jar -> [Help 1]
  144. [ERROR]
  145. [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  146. [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  147. [ERROR]
  148. [ERROR] For more information about the errors and possible solutions, please read the following articles:
  149. [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
  150. tomcat Id list :1723
  151. cp: cannot stat ‘/root/.jenkins/workspace/DeployOrder/order/target/order.war’: No such file or directory
  152. mv: cannot stat ‘order.war’: No such file or directory
  153. Tomcat started.
  154. Finished: SUCCESS

原因:
由于当前项目所需jdk版本和Jenkins中使用的jdk版本不一致导致的,当前项目的pom.xml中定义了java版本为1.8,但是Jenkins中配配置的JDK版本却为1.7

 

image.png

解决办法:
修改Jenkins中系统配置-全局工具配置中jdk版本为项目所需jdk版本即可

 


这个方法是可行的!大家可以试试!!!!完全没问题

jenkins报错说maven插件不兼容和java路径找不到的情况可以参照这个博客。如果是找不到java路径,那么你就用最后面的这个方法好了,对你来说是最好的。而且如果再出先找不到java路径,大家可以看我的这个博客来重新配置一下你的jenkins对Linux系统的java路径:https://blog.csdn.net/wise18146705004/article/details/105577028

但是呢,因为你已经安装了java对不对?那你就不要这样了,我推荐你用这个(
目的在于卸载系统自带的java,然后重新安装一个自己的java,并配置一下java的环境变量,也就是重新再来一次,对你来说可能更好)
https://blog.csdn.net/hui_2016/article/details/69941850。用起来还是很好的。上面讲的很详细,你照着操作一下可以学到不少东西!!!!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/676933
推荐阅读
相关标签
  

闽ICP备14008679号