问题描述
我安装了Java和Maven的Jenkins从属服务器(环境为Debian).我可以在控制台中运行"java -version"和"mvn -version"命令.
I have Jenkins slave with Java and Maven installed (environment is Debian). I can run "java -version" and "mvn -version" commands in console.
但是,当我尝试在Jenkins作业中执行shell命令时,出现"mvn:未找到"错误. Java命令运行正常.
But when I try to execute shell commands in Jenkins job, then I get "mvn: not found" error. Java command works fine.
您能告诉我如何做才能在从站上运行shell"mvn"命令吗?
Can you tell me what should I do to be able to run shell "mvn" command on slave?
推荐答案
在本地运行 mvn --version 以获得Mavan主页路径
run mvn --version locally to get Mavan home path
[[email protected]]# mvn --version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)mvn --version
Maven home: /opt/apache-maven-3.3.9
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: /usr/lib/jvm/jdk1.8.0_131/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-327.18.2.el7.x86_64", arch: "amd64", family: "unix"
然后在运行任何mvn命令之前将以下内容添加到 Execute shell 中.会做到的.
then add the following to Execute shell prior to running any mvn command. That'll do it.
export M2_HOME=/opt/apache-maven-3.3.9 # your Mavan home path
export PATH=$PATH:$M2_HOME/bin
mvn --version
这篇关于"MVN:找不到"在詹金斯奴隶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!