Skip to content
Advertisement

Jenkinsfile task getting faild [Unsupported class file major version 57]

Background:

I got this error earlier [Unsupported class file major version 57]

This error means that my version of Java is incompatible with the one with which Gradle was compiled.

My Gradle version was Gradle 6.0.1 and JDK version was openjdk 13.0.2.

So i downgrade JDK to JDK 11 and issue was resolved.

I was able to run task “./gradlew spotbugsMain” in terminal. As well as in Jenkins using WebUI in a shell command. This jobs works fine and success in return.

Now where the problem is:

I now have to run the jobs using Jenkinsfile instead of a shell command in a Jenkins Project.

So i setup a Jenkins Pipeline for this.

Added my Jenkinsfile and ran the jobs using Jenkins pipeline project.

All my jobs are working fine but “./gradlew spotbugsMain” resulting the same error as earlier [Unsupported class file major version 57]

I checked my Jenkins Project which i am using as shell command to run spotbugs task. it was working fine but Jenkinsfile in Pipeline project is giving error.

I have also added the JDK in Jenkins > Manage Jenkins > Global Tool Configuration > JDK > JDK Installations as

enter image description here

“./gradlew spotbugsMain” working fine in my terminal. Also working fine using Jenkins Project in Jenkins Web UI Where i ran the job as shell command. But not working under a pipeline project which is using Jenkinsfile to run jobs.

My Jenkinsfile is:

pipeline {
    agent any
    stages {
        stage('Spotbugs') {
            steps {
                sh "./gradlew spotbugsMain"
            }
        }

    }
}

Error:

Task :app:spotbugsMain FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:app:spotbugsMain’.

Unsupported class file major version 57

Any help in this problem is appreciated in advance. Thanks

Advertisement

Answer

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement