简体   繁体   English

在Jenkins奴隶上使用Maven

[英]Using maven on a Jenkins slave

We have a Jenkins slave that runs build jobs using Maven. 我们有一个Jenkins奴隶,可以使用Maven运行构建作业。 The .m2 directory exists in the root folder of the user, but the mvn command does not work on the command line. .m2目录位于用户的根文件夹中,但是mvn命令在命令行上不起作用。 Does this mean that Jenkins is set to auto-install tools on the slave? 这是否意味着Jenkins设置为在从站上自动安装工具? 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) M2_HOME(指向Maven安装目录)
  • JAVA_HOME (pointing to Java installation dir) JAVA_HOME(指向Java安装目录)
  • Add %M2_HOME%\\bin (WINDOWS) or $M2_HOME\\bin (LINUX) to PATH environment variable 将%M2_HOME%\\ bin(WINDOWS)或$ M2_HOME \\ bin(LINUX)添加到PATH环境变量

For example, this is my configuration on CentOS 例如,这是我在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 然后您可以在外壳上使用mvn --version进行检查

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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