Skip to content

Instantly share code, notes, and snippets.

@darinpope
Last active October 30, 2024 13:39
Show Gist options
  • Save darinpope/8cc89c823c69b0410fa314f30f536c6f to your computer and use it in GitHub Desktop.
Save darinpope/8cc89c823c69b0410fa314f30f536c6f to your computer and use it in GitHub Desktop.

Gist for https://youtu.be/2-L0WohfsqY

Install Temurin JDK

From CentOS/RHEL/Fedora Instructions:

  • Create RPM repository
cat <<EOF > /etc/yum.repos.d/adoptium.repo
[Adoptium]
name=Adoptium
baseurl=https://packages.adoptium.net/artifactory/rpm/${DISTRIBUTION_NAME:-$(. /etc/os-release; echo $ID)}/\$releasever/\$basearch
enabled=1
gpgcheck=1
gpgkey=https://packages.adoptium.net/artifactory/api/gpg/key/public
EOF
  • Install Temurin 11 (this will fail)

    • dnf -y install temurin-11-jdk
  • Modify /etc/yum.repos.d/adoptium.repo

    • change rocky/$releasever to rocky/8
  • Install Temurin 11 (this will succeed)

    • dnf -y install temurin-11-jdk

Install Jenkins

From Jenkins Redhat Packages:

  • Create RPM repository

    • wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
  • Add repository key

    • rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
  • Install Jenkins

    • dnf -y install jenkins

Configure Jenkins

  • systemctl --full status jenkins
  • systemctl edit jenkins
[Service]
Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Djava.io.tmpdir=/var/cache/jenkins/tmp/ -Dorg.apache.commons.jelly.tags.fmt.timeZone=America/New_York -Duser.timezone=America/New_York"
Environment="JENKINS_OPTS=--pluginroot=/var/cache/jenkins/plugins"
  • mkdir -p /var/cache/jenkins/tmp
  • chown -R jenkins:jenkins /var/cache/jenkins/tmp
  • systemctl show jenkins
  • systemd-analyze verify jenkins.service
  • systemctl start jenkins
  • systemctl --full status jenkins
  • journalctl -u jenkins
@hurrellit
Copy link

Thanks for these great instructions and the YouTube video.. Super helpful!

One minor error above, it should be "systemctl --full status jenkins" on the second to last line. Looks like a "long dash" has got in there instead of two short dashes.

@darinpope
Copy link
Author

Thanks for catching that. Copy and paste strikes again.

@hurrellit
Copy link

Thanks for updating. I'm new to both Rocky and Jenkins (I use Ubuntu mostly so a switch from Debian to Red Hat is taking time!) and this was very useful.

@BilgeKaanGencdogan
Copy link

BilgeKaanGencdogan commented Oct 30, 2024

Hello,
I am getting that error;

[root@localhost ~]# systemd-analyze verify jenkins.service
[root@localhost ~]# systemctl start jenkins
Job for jenkins.service failed because the control process exited with error code.
See "systemctl status jenkins.service" and "journalctl -xeu jenkins.service" for details.

When I run recommended commands, outputs;

[root@localhost ~]# systemctl status jenkins.service
× jenkins.service - Jenkins Continuous Integration Server
     Loaded: loaded (/usr/lib/systemd/system/jenkins.service; disabled; preset: disabled)
    Drop-In: /etc/systemd/system/jenkins.service.d
             └─override.conf
     Active: failed (Result: exit-code) since Tue 2024-10-22 02:24:16 +03; 2min 36s ago
    Process: 51945 ExecStart=/usr/bin/jenkins (code=exited, status=1/FAILURE)
   Main PID: 51945 (code=exited, status=1/FAILURE)
        CPU: 508ms

Oct 22 02:24:15 localhost.localdomain systemd[1]: jenkins.service: Main process exited, code=exited, status=1/FAILURE
Oct 22 02:24:15 localhost.localdomain systemd[1]: jenkins.service: Failed with result 'exit-code'.
Oct 22 02:24:15 localhost.localdomain systemd[1]: Failed to start Jenkins Continuous Integration Server.
Oct 22 02:24:16 localhost.localdomain systemd[1]: jenkins.service: Scheduled restart job, restart counter is at 5.
Oct 22 02:24:16 localhost.localdomain systemd[1]: Stopped Jenkins Continuous Integration Server.
Oct 22 02:24:16 localhost.localdomain systemd[1]: jenkins.service: Start request repeated too quickly.
Oct 22 02:24:16 localhost.localdomain systemd[1]: jenkins.service: Failed with result 'exit-code'.
Oct 22 02:24:16 localhost.localdomain systemd[1]: Failed to start Jenkins Continuous Integration Server.

and

[root@localhost ~]# journalctl -xeu jenkins.service
░░ Support: https://wiki.rockylinux.org/rocky/support
░░ 
░░ Automatic restarting of the unit jenkins.service has been scheduled, as the result for
░░ the configured Restart= setting for the unit.
Oct 22 02:24:16 localhost.localdomain systemd[1]: Stopped Jenkins Continuous Integration Server.
░░ Subject: A stop job for unit jenkins.service has finished
░░ Defined-By: systemd
░░ Support: https://wiki.rockylinux.org/rocky/support
░░ 
░░ A stop job for unit jenkins.service has finished.
░░ 
░░ The job identifier is 8703 and the job result is done.
Oct 22 02:24:16 localhost.localdomain systemd[1]: jenkins.service: Start request repeated too quickly.
Oct 22 02:24:16 localhost.localdomain systemd[1]: jenkins.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://wiki.rockylinux.org/rocky/support
░░ 
░░ The unit jenkins.service has entered the 'failed' state with result 'exit-code'.
Oct 22 02:24:16 localhost.localdomain systemd[1]: Failed to start Jenkins Continuous Integration Server.
░░ Subject: A start job for unit jenkins.service has failed
░░ Defined-By: systemd
░░ Support: https://wiki.rockylinux.org/rocky/support
░░ 
░░ A start job for unit jenkins.service has finished with a failure.
░░ 
░░ The job identifier is 8703 and the job result is failed.

and in case you would ask me, my java version is;

[root@localhost ~]# java -version
openjdk version "11.0.24" 2024-07-16
OpenJDK Runtime Environment Temurin-11.0.24+8 (build 11.0.24+8)
OpenJDK 64-Bit Server VM Temurin-11.0.24+8 (build 11.0.24+8, mixed mode)

any help?

Edit: I solved myself, I forgot to do chown -R jenkins:jenkins /var/cache/jenkins/tmp
PS: For anyone out there, I solved by looking at the log file with journalctl -u jenkins.service --no-pager;
it outputs the error like this;

Exception in thread "main" java.io.UncheckedIOException: Jenkins failed to create a temporary file in /var/cache/jenkins/tmp/: java.io.IOException: No such file or directory

Long story short, do not forget to look log :)

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment