Reputation: 356
I have Jenkins slave with Java and Maven installed (environment is Debian). I can run "java -version" and "mvn -version" commands in console.
But when I try to execute shell commands in Jenkins job, then I get "mvn: not found" error. Java command works fine.
Can you tell me what should I do to be able to run shell "mvn" command on slave?
Upvotes: 3
Views: 15455
Reputation: 637
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"
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
Upvotes: 12
Reputation: 356
I found a solution:
You just have to set proper Environment variable in node configuration like in the picture below.
Upvotes: 2