詹金斯(Jenkins)无法识别Maven [英] Maven not recognized in Jenkins

查看:605
本文介绍了詹金斯(Jenkins)无法识别Maven的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Windows 8上安装了Tomcat 7,并在上面部署了Jenkins.我在Jenkin设置中配置了JDK,Ant和Maven.在Maven部分中,我将名称命名为LocalMaven,将MAVEN_HOME命名为C:\Techie\apache-maven.当我进行测试构建时,它给了我以下错误,即无法识别mvn.bat.然后我通过在CMD中输入mvn命令进行检查.它给出了一些maven语句,这意味着maven在PATH变量中可用.

I have installed Tomcat 7 on Windows 8, on which Jenkins is deployed. I configured the JDK, Ant and Maven in the Jenkin settings. In the Maven section, I gave a name as LocalMaven and the MAVEN_HOME as C:\Techie\apache-maven. When I did a test build, it gave me the following error that the mvn.bat is not recognized. Then I checked by entering mvn command in CMD. It gave some maven statements, which means maven is available in the PATH variables.

在谷歌搜索之后,我在Jenkin-Maven配置中将MAVEN_HOME更改为**%M2_HOME%\bin**.仍然没有用.

After googling, I changed the MAVEN_HOME as **%M2_HOME%\bin** in Jenkin-Maven configuration. Still it did not work.

日志:

  • [workspace] $ cmd.exe /C '"mvn.bat -f HighScoresServiceClient compile && exit %%ERRORLEVEL%%"'

'mvn.bat'不被识别为内部或外部命令, 可操作的程序或批处理文件

'mvn.bat' is not recognized as an internal or external command, operable program or batch file

构建步骤"Invoke top-level Maven targets"将构建标记为失败

Build step 'Invoke top-level Maven targets' marked build as failure

完成:FAILURE

已添加了分析

Jenkins执行的命令是[workspace] $ cmd.exe /C '"mvn.bat -f String-replacer compile && exit %%ERRORLEVEL%%"',其中mvn.bat不是有效命令,因此Jenkins错误如下:'mvn.bat' is not recognized as an internal or external command,我认为Jenkins应该将该命令称为mvn而不是mvn.bat.如果我错了,一些专家可以纠正我吗?如果我是对的,请让我知道如何更改此行为.

The command executed by Jenkins is [workspace] $ cmd.exe /C '"mvn.bat -f String-replacer compile && exit %%ERRORLEVEL%%"' where mvn.bat is not a valid command and so Jenkins errors out as follows that 'mvn.bat' is not recognized as an internal or external command, I think Jenkins should call the command as mvn and not mvn.bat. Can some experts correct me if I am wrong? Please let me know how to change this behaviour if I am right.

已已附加配置

推荐答案

我想您的Tomcat服务器正在作为Windows服务运行.

I suppose your Tomcat server is running as a Windows service.

您是否将MAVEN_HOME和M2_HOME创建为系统环境变量? (适合您的PATH)

Did you create your MAVEN_HOME and M2_HOME as system environment variables? (idem for your PATH)

另一种解决方案是在apache-tomcat/bin/setenv.bat文件中配置变量:

Another solution is to configure your variables in the apache-tomcat/bin/setenv.bat file:

set MAVEN_HOME=C:\Techie\apache-maven
set PATH=%MAVEN_HOME%\bin;%PATH%

这篇关于詹金斯(Jenkins)无法识别Maven的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆