如何在每个Slave节点的Jenkins中配置Maven安装? [英] How to configure Maven installation in Jenkins per individual Slave node?

查看:2828
本文介绍了如何在每个Slave节点的Jenkins中配置Maven安装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在Jenkins中创建Maven作业( New Item => Maven项目),所有默认值并运行它,我收到此错误:

If I create a Maven job in Jenkins (New Item => Maven project) with all defaults and run it, I get this error:

Started by user anonymous
Building on master in workspace /var/lib/jenkins/jobs/job_name/workspace
ERROR: A Maven installation needs to be available for this project to be built.Either your server has no Maven installations defined, or the requested Maven version does not exist.
Finished: FAILURE

Maven从命令行完美运行,只需 mvn

Maven runs perfectly from command line with just mvn.

有一个系统范围的Jenkins配置Maven安装:管理Jenkins => 配置系统 => Maven / Maven安装。如果我使用此Web UI添加Maven安装(通过在 MAVEN_HOME 中提供预先安装的路径为 / usr / share / maven ),作业运行成功。

There is a system-wide Jenkins configuration for Maven installation: Manage Jenkins => Configure System => Maven / Maven installations. And if I add Maven installation using this web UI (by providing pre-installed path in MAVEN_HOME as /usr/share/maven), the job runs SUCCESSFULLY.

全局Jenkins配置没有意义:Maven是按Slave运行的,而不是每个Jenkins运行。

The global Jenkins config does not make sense: Maven is run per Slave, not per Jenkins.

Jenkins运行作业的Slaves动物园可能包含Slave with各种平台,操作系统,不同版本的Maven安装在不同位置的环境。

The zoo of Slaves where Jenkins runs jobs may contain Slaves with various platforms, OSes, environments where different versions of Maven are installed in different locations.

设置环境变量,如 MAVEN_HOME M2_HOME 到Slave节点上整个系统的相同路径不起作用。

Setting environment variables like MAVEN_HOME and M2_HOME to the same path for entire system on Slave node didn't work.

Jenkins Master和Slave都是Linux主机。 Jenkins版本: 1.598

Both Jenkins Master and Slave are Linux hosts. Jenkins version: 1.598

推荐答案

假设你安装了Java和Maven你的奴隶:

Assuming you have Java and Maven installed on your slave:


  1. 转到管理Jenkins - >管理节点

  2. 点击节点上的配置图标您希望配置

  3. 向下滚动到节点属性并勾选工具位置复选框

  4. 填写Java和Maven的选项。

  1. Go to Manage Jenkins -> Manage Nodes
  2. Click configure icon on the node you wish to configure
  3. Scroll down to 'Node Properties' and tick the 'Tool Locations' checkbox
  4. Fill in the options for Java and Maven.

它现在应该可以工作(即使你在主服务器上配置了Maven安装)。

It should now work (even if you have configured a Maven installation on the master).

这篇关于如何在每个Slave节点的Jenkins中配置Maven安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆