Jenkins Blue Ocean:Maven没有看到Java

时间:2018-04-09 16:34:48

标签: java jenkins jenkins-blueocean

即使路径存在,我收到错误“/var/jenkins_home/tools/hudson.model.JDK/jdk8/bin/java:not found:”:

   

[edi-debatcher_master-LNI22Y2C5V3VECCBCFPVB3ZUWJJNMLK6LIFEQ6V3OYH52T74NU3A@2] Running shell script
+ echo PATH = /var/jenkins_home/tools/hudson.model.JDK/jdk8/bin:/var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.5.3/bin:/var/jenkins_home/tools/hudson.model.JDK/jdk8/bin:/var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.5.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
PATH = /var/jenkins_home/tools/hudson.model.JDK/jdk8/bin:/var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.5.3/bin:/var/jenkins_home/tools/hudson.model.JDK/jdk8/bin:/var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.5.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
+ echo M2_HOME = /var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.5.3
M2_HOME = /var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.5.3
+ mvn -version
/var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.5.3/bin/mvn: exec: line 199: /var/jenkins_home/tools/hudson.model.JDK/jdk8/bin/java: not found

我正在使用Jenkins Blue Ocean功能,GitHub Jenkinsfile。我在全局工具配置中定义了“jdk8”和“Maven 3.5.3”,选中了“自动安装”。

这是我的Jenkinsfile:


    pipeline {
      agent any
      stages {
        stage('Initialize') {
          steps {
            sh '''
               echo "PATH = ${PATH}"
               echo "M2_HOME = ${M2_HOME}"
               mvn --version 
               '''
          }
        }
        stage('Build') {
          steps {
            sh 'mvn -Dmaven.test.failure.ignore=true install'
          }
          post {
            success {
              junit 'target/surefire-reports/**/*.xml'
            }
          }
        }
      }
      tools {
        maven 'Maven 3.5.3'
        jdk 'jdk8'
      }
      post {
        always {
        deleteDir()
        }
      }
    }

3 个答案:

答案 0 :(得分:1)

问题是Oracle JDK自动安装在我的系统上没有做任何事情(通过检查Jenkins' Java系统属性来确认)。我发现openjdk 1.8恰好已经在那个容器上了,所以我手动指向JAVA_HOME而不是依赖于Oracle JDK自动安装。

答案 1 :(得分:1)

您为系统运行的文件版本错误(此处为java)。

问题: 该文件在那里,无法执行。错误消息是“没有这样的文件或目录”

解决方案: You are running the wrong file version for your system

例如,如果您使用Alpine Linux在since Alpine uses musl libc. The Oracle Java binaries only run on glibc.

的Docker容器中运行Jenkins安装,则可能发生此问题。

答案 2 :(得分:0)

一旦我将项目JDK设置更改为system,我的构建就越过了这个错误。