I have imported the jenkins jobs from existing jenkins server from another machine. But the problem is, it has the JDK referenced as per the old machines and I want to change it to use the JDK configured in my new jenkins. But I am unable to find any way of doing this. So, please if you have come across this situation and found a way then please help me too.
Go to "Manage Jenkins (in german: Jenkins verwalten)", then "Configuration of tools (in german: Konfiguration der Hilfsprogramme)" and there should be a section regarding "JDK". Here, you can manage your different java versions (whether to download or use local ones):
The following is a question to understand historic context and decision process for the change. Was this related to the systemd changes or something else? Is there differing guidance for docker images vs package installation (into standard VM; ie: sudo yum install jenkins?
Previously, the package was installed in /usr/share/jenkins/jenkins.war. That was a non-standard directory in the standard directory hierarchy. The systemd packaging transition was a good opportunity to place the archive in the same directory that contains other Java archives and to follow the instructions from the operating system providers about the location where packages should install their jar files.
There are no plans to replace this functionality. Connect agents to Jenkins on Java 11 with plugins like SSH Build Agents Plugin, with operating system command line calls to java -jar agent.jar, or using containers.
Short of it is - java used for builds is, in most cases, unrelated to java used for controller/agents. You can use the Tool system to install right versions of JDK as needed. That said, I was under impression that Jenkins did not yet support 17 for running Controller/Agent (you can use it for builds though)
A label can be assigned to an agent. The label can be used the represent the availability of a specific tool version on that agent. Labels could be java8, java11, and java17 to indicate that those Java versions are available on the agent. Labels could be linux, windows, macOS, FreeBSD, or OpenBSD to indicate the operating system hosting the agent. Labels could be git-1.8 or git-2.36 to indicate the specific version of a tool that is installed on the agent.
This java Path will be used to start the jvm. (/mycustomjdkpath/bin/java ) If empty Jenkins will search java command in the agent
Expressions such as key or key may be declared in the java Path and will be expanded to values of matching keys declared in the list of environment variables of this node, or if not present, in the list of global environment variables.
(from SSH Build Agents plugin)
You definitily have an outdated setup on the old agents. The jlnp endpoint changed to jenkins-agent (instead of slave-agent, so this still can be ues). I would really open the agent page on the controller, move the old agent dir contents on the agent away and execute the shown commands (all lof them!) afresh.
There is also a video from Darin Pope that offers ways that Jenkins controllers can provide many different Java versions for use by jobs on those controllers. Those techniques will allow Pipeline jobs and freestyle jobs to use the Java version of their choice while the Jenkins controller runs Java 11 or Java 17. We use those techniques on ci.jenkins.io to build and test with Java 11, Java 17, Java 19, and even Java 8 using Pipeline jobs.
Error while serving :8080/descriptorByName/hudson.security.LDAPSecurityRealm/validate java.lang.NullPointerException at hudson.security.LDAPSecurityRealm$DescriptorImpl.validate(LDAPSecurityRealm.java:1589) at hudson.security.LDAPSecurityRealm$DescriptorImpl.validate(LDAPSecurityRealm.java:1589ity) $DescriptorImpl.doValidate(LDAPSecurityRealm.java:1544) at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:710) at org.kohsuke.stapler.Function$MethodFunction.invoke:(Function.javaction.java) ) Caused: java.lang.reflect.InvocationTargetException at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:401) at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:409) at org .kohsuke.stapler.interceptor.RequirePOST$Processor.invoke(RequirePOST.java:78) at org.kohsuke.stapler.PreInvokeInterceptedFunction.invoke(PreInvokeInterceptedFunction.java:26) at org.kohsuke.bindlerAnd.Function. :207) at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java :140) at org.kohsuke.stapler.MetaClass$11.doDispatch(MetaClass.java:558) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:59) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.tryInvoke(Stapler .java:766) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:898).
On the Jenkins Main Page, to the Left click "Manage Jenkins." Access "Global Tool Configuration" menu, and under this menu there is a location about half way down that should say "JDK Installations." Click that button and it will open a new menu where you can add an alternate JDK. Once added, you go into the project you want to build and click "Configure." Again, about half way down will be a "JDK" drop down. The new JDK will now appear and you can select it to build your project.However, if you mean you want the entire service to run from a different VM, that is a little trickier. Jenkins start script is written to try and "guess" your VM so it has easier installation across multiple Linux flavors. Find the start script (Red Hat RPM install places it in /etc/rc.d/init.d/jenkins) and read through it. You'll find a section labelled "candidates" and notice how the loop runs through the possible JVMs that might be on a system. You could edit this list to only be the VM you want to use and then stop/start to force it to use the VM you want. Make sure you copy the script before you edit it, just in case.
This is what I had to do in order to make Jenkins use Java 8 on a Ubuntu system with Java 11 set as the default. It was not acceptable for me to just apt remove openjdk-11-jdk-headless or update-alternatives --config java and choose Java 8 as the default. The caveat with editing the startup file is that it might be is overwritten every time Jenkins is updated.
This might not be the best approach but my workaround for this was to use JDK11 as the default, and then inside my job use environment variables so that java pointed to JDK8 (swap in your JDK versions for JDK11 and 8)
So uninstalled the Java 11 and tried to install Java 8. While installing java 8, the Jenkins messages incorrect java version repeatedly was coming. So I completely removed both Java 11(JDK) and Java 8(JDK) and made sure no folders are there in /usr/bin and /usr/lib/jvm for both java 11 and java 8. When I installed java 8 the system says JDK 8 installed but im not able to find any java version in my system. Why?
I've just encountered this problem, and it actually looks like an issue in /etc/init.d/jenkins testing for the Java version. I just posted a solution here: -moore.com/works/5054500/ubuntu-and-jenkins-found-an-incorrect-java-version , sharing below for those who find this question as first google hit.
Digging around a bit I noticed the init script in /etc/init.d/jenkins that the script, at lines 56-60, was using SED to extract the version from the java - version command into a numeric value, but the regular expression was a bit to broad
Jenkins requires Java 8 jdk to be installed.Check your java version by command$ java -versionIf you have more than one java installed on your machineuse the command$ sudo update-alternatives --config javaThis will provide a list of java versions on your machines.Use the comands to install jenkins$ sudo apt update$ sudo apt install jenkins
To change the port number to say 9090 please edit using sudo$ sudo vim /etc/default/jenkins8080 is the most commonly used portFind 8080 and change to 9090Save the file using :wq for Vim editorOpen browser :9090 to start config of jenkins
I got this error after upgrading java from 8 to 11; because I had manually upgraded my jenkins on ubuntu by swapping in the new war. So, my old install had persisted the /etc/init.d/jenkins file with the bug.
To use this repository, run the following command: sudo wget -O /etc/yum.repos.d/jenkins.repo -stable/jenkins.repo sudo rpm --import -stable/jenkins.io-2023.key If you've previously imported the key from Jenkins, the rpm --import will fail because you already have a key. Please ignore that and move on. yum install fontconfig java-17-openjdk yum install jenkins The rpm packages were signed using this key:
The Docker image must be the image provided by CloudBees: jenkins-enterprise, jenkins-operating-center for the CloudBees Jenkins Platform rolling release and jenkins-enterprise-fixed and jenkins-operations-center-fixed for the CloudBees Jenkins Platform fixe release
What I would do is check read/write permission settings on /var/lib/jenkins/config.xml, then remove the xml in /var/lib/jenkins/ that has the plugin's name in its filename. (backup it before just in case)
760c119bf3