【发布时间】:2018-10-08 07:00:05
【问题描述】:
我已经在 cmd 中手动编译了 maven,它是成功的。 但是,当我尝试运行 jenkins 作业时,它是在说
"'mvn' is not recognized as an internal or external command,
operable program or batch file."
Jenkins 控制台输出:
enter code hereStarted by user prakash peram
在工作区 C:\Program Files (x86)\Jenkins\workspace\atmosphere3 中构建
git.exe rev-parse --is-inside-work-tree # timeout=10 从远程 Git 存储库获取更改 git.exe 配置 remote.origin.url https://github.com/g0t4/jenkins2-course-spring-boot.git # timeout=10 从https://github.com/g0t4/jenkins2-course-spring-boot.git 获取上游更改 git.exe --version # timeout=10 git.exe fetch --tags --progress https://github.com/g0t4/jenkins2-course-spring-boot.git +refs/heads/:refs/remotes/origin/ git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10 git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10 签出修订版 4bde91e33e2860b2aab142028c04eff37b7791f2(参考/远程/起源/主) git.exe 配置 core.sparsecheckout # timeout=10 git.exe 结帐 -f 4bde91e33e2860b2aab142028c04eff37b7791f2 提交消息:“添加 jacoco 代码覆盖率” git.exe rev-list --no-walk 4bde91e33e2860b2aab142028c04eff37b7791f2 # timeout=10 [atmosphere3] $ cmd.exe /C "mvn -f spring-boot-samples/spring-boot-sample-atmosphere/pom.xml compile && exit %%ERRORLEVEL%%" 'mvn' 未被识别为内部或外部命令, 可运行的程序或批处理文件。 构建步骤“调用顶级 Maven 目标”将构建标记为失败 完成:失败
我已经在环境变量中设置了 MVN_HOME 和 M2_HOME。
如果需要,请寻求更多信息。
【问题讨论】:
-
您是否将 %M2_HOME%\bin 添加到 PATH 环境变量中?
-
我需要在哪里指定路径?在詹金斯?我在maven安装中添加了安装路径。
-
检查“4.添加到路径”部分here。
-
对于手动编译,它按预期工作并获得了所需的输出。但我需要在詹金斯做这件事。那是抛出错误
-
创建并运行包含以下内容的 bat 文件:
cd "C:\Program Files (x86)\Jenkins\workspace\atmosphere3" cmd.exe /C "mvn -f spring-boot-samples/spring-boot-sample-atmosphere/pom.xml compile && exit %%ERRORLEVEL%%" pause让我知道它是否有效。你也尝试过我之前的提示吗?