首页 > 解决方案 > Maven 和 jenkins 'mvn' 未被识别为内部或外部命令、可运行程序或批处理文件

问题描述

我已经在cmd中手动编译了maven,它是成功的。但是,当我尝试运行 jenkins 工作时,它说

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

詹金斯控制台输出:

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 config 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 --进度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 (refs/remotes/origin/master) git.exe config core.sparsecheckout # timeout=10 git.exe checkout -f 4bde91e33e2860b2aab142028c04eff37b7791f2" Commit message: "Adding in rev-list --no code coverage git.exe 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。

如果需要,请寻求更多信息。

标签: mavenjenkins

解决方案


在仪表板左侧面板的jenkins里面我们找到了通用设置,然后在全局工具里面我们可以像windows一样配置JDK和MAVEM环境,但是这次将在localhost jenkins中使用maven和jdk的路径程序文件

在此处输入图像描述

在此处输入图像描述


推荐阅读