Hi guys in this article you will learn about how to solve the Jenkins issue, after you successfully installed the Jenkins server it keeps stopping with the exit code as 1.
This is due to the Java issue, you have installed two Java versions into your Linux machine.
Issue
================
I was getting the below error whenever I tried to start the Jenkins server, the error mentioned below two important things to note
First is error message: “Failed to start Jenkins Continuous Integration Server”
Second is failure message: Process: 6177 ExecStart=/usr/bin/jenkins (code=exited, status=1/FAILURE)
[root@rhel86 ~]# systemctl -l status jenkins
● jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/usr/lib/systemd/system/jenkins.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2023-02-13 05:42:36 CST; 2min 6s ago
Process: 6177 ExecStart=/usr/bin/jenkins (code=exited, status=1/FAILURE)
Main PID: 6177 (code=exited, status=1/FAILURE)
Feb 13 05:42:36 rhel86 systemd[1]: jenkins.service: Service RestartSec=500ms expired, scheduling restart.
Feb 13 05:42:36 rhel86 systemd[1]: jenkins.service: Scheduled restart job, restart counter is at 5.
Feb 13 05:42:36 rhel86 systemd[1]: Stopped Jenkins Continuous Integration Server.
Feb 13 05:42:36 rhel86 systemd[1]: jenkins.service: Start request restarted too quickly.
Feb 13 05:42:36 rhel86 systemd[1]: jenkins.service: Failed with result 'exit-code'.
Feb 13 05:42:36 rhel86 systemd[1]: Failed to start Jenkins Continuous Integration Server.
Quick Fix
===================
In order to fix the above issue you should configure the correct Java version, in my machine I had installed Java 1.8 and Java 11, so I have to fix it by running an alternate config command. The alternate command will point to the right Java program that needs to be used by Jenkins Server. yes run the alternatives command and restart the Jenkins server as shown below.
[root@rhel86 ~]#
[root@rhel86 ~]# alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
*+ 1 java-1.8.0-openjdk.ppc64le (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.362.b09-2.el8_7.ppc64le/jre/bin/java)
2 java-11-openjdk.ppc64le (/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-2.el8_7.ppc64le/bin/java)
Enter to keep the current selection[+], or type selection number: 2
[root@rhel86 ~]#
[root@rhel86 ~]# systemctl restart jenkins
[root@rhel86 ~]#
Check Jenkins status
==========================
After configuring the right Java version that needs to be used by Jenkins and restarting the Jenkins server check the Jenkins program status. As shown below.
[root@rhel86 ~]#
[root@rhel86 ~]# sudo systemctl status jenkins
● jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/usr/lib/systemd/system/jenkins.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2023-02-13 05:53:44 CST; 6s ago
Main PID: 6442 (java)
Tasks: 101 (limit: 97076)
Memory: 2.2G
CGroup: /system.slice/jenkins.service
└─6442 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080
Feb 13 05:53:38 rhel86 jenkins[6442]: Jenkins initial setup is required. An admin user has been crrhel86ed and a password generated.
Feb 13 05:53:38 rhel86 jenkins[6442]: Please use the following password to proceed to installation:
Feb 13 05:53:38 rhel86 jenkins[6442]: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Feb 13 05:53:38 rhel86 jenkins[6442]: This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword
Feb 13 05:53:38 rhel86 jenkins[6442]: *************************************************************
Feb 13 05:53:44 rhel86 jenkins[6442]: 2023-02-13 11:53:44.971+0000 [id=159] INFO jenkins.InitReactorRunner$1#onAttained: Completed ini>
Feb 13 05:53:44 rhel86 jenkins[6442]: 2023-02-13 11:53:44.982+0000 [id=35] INFO hudson.lifecycle.Lifecycle#onReady: Jenkins is fully u>
Feb 13 05:53:44 rhel86 systemd[1]: Started Jenkins Continuous Integration Server.
Feb 13 05:53:45 rhel86 jenkins[6442]: 2023-02-13 11:53:45.020+0000 [id=153] INFO h.m.DownloadService$Downloadable#load: Obtained the u>
Feb 13 05:53:45 rhel86 jenkins[6442]: 2023-02-13 11:53:45.020+0000 [id=153] INFO hudson.util.Retrier#start: Performed the action check>
[root@rhel86 ~]#
Conclusion
==================
Do remember this is a one of the solutions to fix the Jenkins unable to start issue by configuring the Java version.
If you are facing any other Jenkins issues comment down below.
0 Comments