简体   繁体   中英

Using maven on a Jenkins slave

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM