Java version error in jenkins pipeline

Hi all,

I am developing a jenkins plugin for my company and after dropping support for java 8, I updated the plugin and its dependencies to latest versions and everything is working perfectly on my local environment. But when I push latest code to github repo and trigger the jenkins pipeline, it seems that the pipeline uses Java 8 and build is failing. How am I suppose to use make/force the pipeline to use Java 11 or 18, how can I configure it ? Here is the error message. Any help would be greatly appreciated.

Hi @keremozben , is it a public plugin (so we can check the Jenkinsfile and help you) or is it a closed source plugin?

In the screenshot that you are showing, the mvn command reports that it is using JDK8, whcih explains the behavior.

The Maven command line (mvn) selects the JDK to use by looking at the environment variable JAVA_HOME or searching for the binary java in the PATH.

=> These settings depends a lot on “wherwhich Jenkins controller runs this pipeline” : can you explain if it is (the public controller for the CI of Jenkins public plugins) or is it a Jenkins controller in your organization?

If it is the 2nd, then you have to search for the Jenkinsfile of the pipeline to find what kind of agent is used (or if a “Jenkins tool” is used) to determine how is Maven installed and configured.

Hi @dduportal ,

It is a public plugin, here is the repository link: GitHub - jenkinsci/netsparker-cloud-scan-plugin: Allows users to start security scans via Netsparker Enterprise

This pipeline runs on

You need to set the JDK in your Jenkinsfile. See documentation at GitHub - jenkins-infra/pipeline-library: Collection of custom steps and variables for our Jenkins instance(s).

Example: warnings-ng-plugin/Jenkinsfile at b57a36462485f64cafdec8771386bdffbae35d4e · jenkinsci/warnings-ng-plugin · GitHub

Perfect !


So you might want to try buildPlugin(jdkVersions: [11]) for instance (or look at configurations if you want a finer grain).

BTW I would recommend using pull request flow even if you are the sole committer and maintainer, just so that you can check that proposed changes pass CI.

Thank you so much @uhafner @dduportal I configured properly and it works.