How to fix jenkins installation error on ubuntu linux

● jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Mon 2022-11-28 05:07:42 UTC; 8ms ago
Process: 22182 ExecStart=/usr/bin/jenkins (code=exited, status=1/FAILURE)
Main PID: 22182 (code=exited, status=1/FAILURE)

Nov 28 05:07:42 ip-172-31-19-156 systemd[1]: jenkins.service: Main process exited, code=exited, status=1/FAILURE
Nov 28 05:07:42 ip-172-31-19-156 systemd[1]: jenkins.service: Failed with result ‘exit-code’.
Nov 28 05:07:42 ip-172-31-19-156 systemd[1]: Failed to start Jenkins Continuous Integration Server.
dpkg: error processing package jenkins (–configure):
installed jenkins package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
jenkins
E: Sub-process /usr/bin/dpkg returned an error code (1)

suggests that you should read the system logs with the command:

# journalctl -u jenkins

That may tell you that Jenkins is trying to use Java 11 but your system is configured to use Java 8. It may tell you that your system does not have Java installed. It may provide other hints about what is causing the Jenkins service to not start on your machine.

You may also want to read and assure that you follow all the installation instructions.

I have installed java1.8 only, After i put "journalctl -u jenkins " command … i am getting below – Logs begin at Sun 2022-11-27 15:40:45 UTC, end at Mon 2022-11-28 05:17:01 UTC. –
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: Starting Jenkins Continuous Integration Server…
Nov 27 16:12:09 ip-172-31-19-156 jenkins[17844]: jenkins: invalid Java version: openjdk version “1.8.0_352”
Nov 27 16:12:09 ip-172-31-19-156 jenkins[17844]: OpenJDK Runtime Environment (build 1.8.0_352-8u352-ga-1~20.04-b08)
Nov 27 16:12:09 ip-172-31-19-156 jenkins[17844]: OpenJDK 64-Bit Server VM (build 25.352-b08, mixed mode)
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: jenkins.service: Main process exited, code=exited, status=1/FAILURE
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: jenkins.service: Failed with result ‘exit-code’.
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: Failed to start Jenkins Continuous Integration Server.
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: jenkins.service: Scheduled restart job, restart counter is at 1.
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: Stopped Jenkins Continuous Integration Server.
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: Starting Jenkins Continuous Integration Server…
Nov 27 16:12:09 ip-172-31-19-156 jenkins[17918]: jenkins: invalid Java version: openjdk version “1.8.0_352”
Nov 27 16:12:09 ip-172-31-19-156 jenkins[17918]: OpenJDK Runtime Environment (build 1.8.0_352-8u352-ga-1~20.04-b08)
Nov 27 16:12:09 ip-172-31-19-156 jenkins[17918]: OpenJDK 64-Bit Server VM (build 25.352-b08, mixed mode)
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: jenkins.service: Main process exited, code=exited, status=1/FAILURE
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: jenkins.service: Failed with result ‘exit-code’.
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: Failed to start Jenkins Continuous Integration Server.
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: jenkins.service: Scheduled restart job, restart counter is at 2.
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: Stopped Jenkins Continuous Integration Server.
Nov 27 16:12:09 ip-172-31-19-156 systemd[1]: Starting Jenkins Continuous Integration Server…
Nov 27 16:12:10 ip-172-31-19-156 jenkins[18065]: jenkins: invalid Java version: openjdk version “1.8.0_352”
Nov 27 16:12:10 ip-172-31-19-156 jenkins[18065]: OpenJDK Runtime Environment (build 1.8.0_352-8u352-ga-1~20.04-b08)

The Java requirements page (linked from the installing page) says that you must have Java 11 or Java 17. Java 8 is not supported by recent Jenkins versions

The message “invalid Java version” is telling you that you need a supported version of Java. Jenkins supports Java 11 and Java 17 for new installs. Install and configure Java 11 or Java 17.

1 Like

yes frist remove java-1.8 -->yum remove java-1.8* and install openjdk 11 or 17 this has worked for me

Thank you brothers @MarkEWaite @veereshalladi

can you fix this
INFO] Copying webapp resources [/var/lib/jenkins/workspace/proj/src/main/webapp]
[INFO] Webapp assembled in [55 msecs]
[INFO] Building war: /var/lib/jenkins/workspace/proj/target/maven-web-application.war
[INFO] WEB-INF/web.xml already added, skipping
[WARNING] Attempt to (de-)serialize anonymous class org.jfrog.hudson.maven2.MavenDependenciesRecorder$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.055 s
[INFO] Finished at: 2022-12-13T17:35:37Z
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /var/lib/jenkins/workspace/proj/pom.xml to com.mt/maven-web-application/0.0.1-SNAPSHOT/maven-web-application-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/proj/target/maven-web-application.war to com.mt/maven-web-application/0.0.1-SNAPSHOT/maven-web-application-0.0.1-SNAPSHOT.war
channel stopped
SSH: Connecting from host [ip-172-31-92-148]
SSH: Connecting with configuration [ansible] …
SSH: EXEC: completed after 600 ms
SSH: Disconnecting configuration [ansible] …
ERROR: Exception when publishing, exception message [Exec exit status not zero. Status [1]]
Build step ‘Send build artifacts over SSH’ changed build result to UNSTABLE
Finished: UNSTABLE