本文介绍了“mvn:未找到"在詹金斯奴隶的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了 Java 和 Maven 的 Jenkins slave(环境是 Debian).我可以在控制台中运行java -version"和mvn -version"命令.

I have Jenkins slave with Java and Maven installed (environment is Debian). I can run "java -version" and "mvn -version" commands in console.

但是当我尝试在 Jenkins 作业中执行 shell 命令时,我得到mvn: not found"错误.Java 命令运行良好.

But when I try to execute shell commands in Jenkins job, then I get "mvn: not found" error. Java command works fine.

你能告诉我我应该怎么做才能在slave上运行shellmvn"命令吗?

Can you tell me what should I do to be able to run shell "mvn" command on slave?

推荐答案

在本地运行 mvn --version 获取 Mavan 主路径

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"

然后在运行任何 mvn 命令之前将以下内容添加到 Execute shell.这样就可以了.

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

这篇关于“mvn:未找到"在詹金斯奴隶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:52