Jenkins maven 构建在 linux 机器中失败

Jenkins maven build fail in linux machine

我的 maven 命令在 windows jenkins 服务器上执行得很好,但是当我尝试在 linux 机器上执行时,构建失败了

我已经尝试 Shell 命令构建为 below :

mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:copy -Dartifact=com.uhg.optum.acc:cores-binaries:%PLATFORM_CORE_VERSION% -DoutputDirectory=. -Dmdep.useBaseVersion=true

控制台输出 :

[EnvInject] - Loading node environment variables. Building remotely on BuildSwarm-6d98547c91e1-apsrp4109.uhc.com (docker-maven-slave) in workspace /home/jenkins/workspace/2.3.0 Deployment Artifacts (QualityMeasures-Platform) [2.3.0 Deployment Artifacts (QualityMeasures-Platform)] $ /bin/sh -xe /tmp/hudson3262693666907249961.sh + mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:copy -Dartifact=com.uhg.optum.acc:cores-binaries:%PLATFORM_CORE_VERSION% -DoutputDirectory=. -Dmdep.useBaseVersion=true /tmp/hudson3262693666907249961.sh: line 2: mvn: command not found Build step 'Execute shell' marked build as failure Archiving artifacts Finished: FAILURE

请帮帮我

您的 shell 脚本似乎失败了,因为它在此节点上找不到 maven。检查是否可以看到在 Manage Jenkins -> System Information 上定义为 M2_HOME 环境变量的 maven 安装目录。您还可以使用 env 命令在您的终端上进行检查。

另外%PLATFORM_CORE_VERSION%用于在windows下解引用环境变量,在Unix机器下使用$PLATFORM_CORE_VERSION(只要配置)