Lab: Install Jenkins on a VM Guide

Leaving this here for future users to be able to get past this lab until this vm is updated. This fix worked as of 5/22/24.

The primary cause of issue with this lab is the fact that java17-openjdk isn’t avalible in the deafult repo provided by the vm.

Installing Java

Navigate to the archive download copy the link to the tar.gz of Java 17

wget <java download link>
tar xvf openjdk-17.0.2_linux-x64_bin.tar.gz
sudo mv jdk-17.0.2/ /opt/

sudo tee /etc/profile.d/jdk17.sh <<EOF
export JAVA_HOME=/opt/jdk-17.0.2
export PATH=\$PATH:\$JAVA_HOME/bin
EOF

With your new file created in profile.d reload it pull the changes into the current terminal session.

source /etc/profile.d/jdk17.sh

Validate your config chagnes were correct

java --version

These commands will download the version of java. You will untar the archive downloaded and move it into your /opt dirctory. Use this tee command you’ll set your JAVA_HOME and add it to your path.

Editing Jenkins config

Now that you have java downloaded Jenkins will still not work when you try to run it. Looking in the logs with sudo journalctl -xe shows that Jenkins still can’t find the java you downloaded.

In order to permentantly fix this issue we’re going to have to edits Jenkins system.d init files.

sudo systemctl cat jenkins

Shows the current jenkins system.d init file. We’ll use this to grab our environment variables that we’re going to override.

sudo systemctl edit jenkins

Paste in this section into this override file

[Service]
Environment="JAVA_HOME=/opt/jdk-17.0.2"
Environment="JENKINS_PORT=8090"

Now when you start jenkins it should start right up with the correct port to pass the lesson.

The perfect guide to resolve the issue! Thanks a lot!