Install Jenkins on a VM (Lab) Issue

I’m having problems starting Jenkins for this lab exercise.

I’m getting this everytime I run “sudo systemctl start jenkins”:

$ sudo systemctl start jenkins
Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.

systemctl status jenkins gives this:

# systemctl status jenkins
● jenkins.service - Jenkins Continuous Integration Server
   Loaded: loaded (/usr/lib/systemd/system/jenkins.service; enabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Tue 2024-01-02 13:09:21 UTC; 1min 26s ago
  Process: 79026 ExecStart=/usr/bin/jenkins (code=exited, status=1/FAILURE)
 Main PID: 79026 (code=exited, status=1/FAILURE)

Jan 02 13:09:21 centos-host systemd[1]: Failed to start Jenkins Continuous Integration Server.
Jan 02 13:09:21 centos-host systemd[1]: Unit jenkins.service entered failed state.
Jan 02 13:09:21 centos-host systemd[1]: jenkins.service failed.
Jan 02 13:09:21 centos-host systemd[1]: jenkins.service holdoff time over, scheduling restart.
Jan 02 13:09:21 centos-host systemd[1]: Stopped Jenkins Continuous Integration Server.
Jan 02 13:09:21 centos-host systemd[1]: start request repeated too quickly for jenkins.service
Jan 02 13:09:21 centos-host systemd[1]: Failed to start Jenkins Continuous Integration Server.
Jan 02 13:09:21 centos-host systemd[1]: Unit jenkins.service entered failed state.
Jan 02 13:09:21 centos-host systemd[1]: jenkins.service failed.

Journalctl -xe gives this:

Jan 02 13:09:21 centos-host systemd[1]: jenkins.service failed.
Jan 02 13:09:21 centos-host systemd[1]: jenkins.service holdoff time over, scheduling restart.
Jan 02 13:09:21 centos-host systemd[1]: Stopped Jenkins Continuous Integration Server.
-- Subject: Unit jenkins.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit jenkins.service has finished shutting down.
Jan 02 13:09:21 centos-host systemd[1]: Starting Jenkins Continuous Integration Server...
-- Subject: Unit jenkins.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit jenkins.service has begun starting up.
Jan 02 13:09:21 centos-host systemd[1]: systemd-journald.service: Couldn't add fd to fd store: Operation n
Jan 02 13:09:21 centos-host jenkins[79026]: jenkins: failed to find a valid Java installation
Jan 02 13:09:21 centos-host systemd[1]: jenkins.service: main process exited, code=exited, status=1/FAILUR
Jan 02 13:09:21 centos-host systemd[1]: Failed to start Jenkins Continuous Integration Server.
-- Subject: Unit jenkins.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit jenkins.service has failed.
-- 
-- The result is failed.
Jan 02 13:09:21 centos-host systemd[1]: Unit jenkins.service entered failed state.
Jan 02 13:09:21 centos-host systemd[1]: jenkins.service failed.
Jan 02 13:09:21 centos-host systemd[1]: jenkins.service holdoff time over, scheduling restart.
Jan 02 13:09:21 centos-host systemd[1]: Stopped Jenkins Continuous Integration Server.
-- Subject: Unit jenkins.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit jenkins.service has finished shutting down.
Jan 02 13:09:21 centos-host systemd[1]: start request repeated too quickly for jenkins.service
Jan 02 13:09:21 centos-host systemd[1]: Failed to start Jenkins Continuous Integration Server.
-- Subject: Unit jenkins.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit jenkins.service has failed.
-- 
-- The result is failed.
Jan 02 13:09:21 centos-host systemd[1]: Unit jenkins.service entered failed state.
Jan 02 13:09:21 centos-host systemd[1]: jenkins.service failed.
Jan 02 13:10:40 centos-host sudo[82731]:      bob : TTY=pts/0 ; PWD=/home/bob ; USER=root ; COMMAND=/bin/b
Jan 02 13:10:40 centos-host sudo[82731]: pam_unix(sudo-i:session): session opened for user root by (uid=0)
lines 653-699/699 (END)

Please advise.

Did you install Java? If so which version?

I followed the link posted on the lab - https://www.jenkins.io/doc/book/installing/linux/#red-hat-centos

The command was:

sudo yum install fontconfig java-17-openjdk

Run Jenkins in the foreground to see what the error is.

I managed to make it work by installing an older version of Java. Perhaps this can be updated?

Actually you are right, these instructions used to work but they are incorrect right now.

The instructions were updated 7 months ago to use OpenJDK version 17, however Centos 7 does not have OpenJDK 17 - you can use OpenJDK 11, it is in the supported list.

Update Linux installation for Java 17 (#6502) · jenkins-infra/jenkins.io@21e7185 (github.com)