• 使用pipeline的时候mvn显示没有这个命令,但是java这个命令确实有的。
  • 解决步骤:
  • 从pipeline中输出环境变量:printenv
    发现里面PATH是这个
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

那我就去看这两个目录下面的命令。
然后只有这个

[lidengyin@ldy bin]$ ls -l | grep java
lrwxrwxrwx    1 root root          22 Apr  3 10:45 java -> /etc/alternatives/java
lrwxrwxrwx    1 root root          23 Apr  3 10:46 javac -> /etc/alternatives/javac

没有maven,这就好办了,加一个软链接

sudo ln -s /usr/local/software/apache-maven-3.6.3/bin/mvn /usr/bin/mvn

sudo ln -s /usr/local/software/apache-maven-3.6.3/bin/mvn /usr/local/bin/mvn

  • 测试结果
+ java -version
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)
+ mvn --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/software/apache-maven-3.6.3
Java version: 1.8.0_241, vendor: Oracle Corporation, runtime: /usr/local/software/jdk1.8.0_241/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1062.1.1.el7.x86_64", arch: "amd64", family: "unix"

都可以了,成功

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐