Question

We have a Jenkins slave that runs build jobs using Maven. The .m2 directory exists in the root folder of the user, but the mvn command does not work on the command line. Does this mean that Jenkins is set to auto-install tools on the slave? If so how could I configure that machine to allow me to run builds by hand.

Was it helpful?

Solution

You need to add the following environtment variables (as user or system variables)

  • M2_HOME (pointing to maven installation dir)
  • JAVA_HOME (pointing to Java installation dir)
  • Add %M2_HOME%\bin (WINDOWS) or $M2_HOME\bin (LINUX) to PATH environment variable

For example, this is my configuration on CentOS

export JAVA_HOME=/opt/java/jdk1.6.0_43
export PATH=${JAVA_HOME}/bin:${PATH}

export M2_HOME=/opt/apache/maven
export PATH=${M2_HOME}/bin:${PATH}

Then you can check using mvn --version on your shell

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top