How to Create Jenkins Slave on Linux

Most of the articles I find on creating a permanent Jenkins slave on Linux requires the slave node to be exposed to public Internet. I want the Linux slave to be pinging Jenkins master just like Windows service. Here is the way I came up with.

Install Prerequisites

  • Java (sudo dnf install java-11-openjdk.x86_64)
    • Check if the Java has been installed. (java -version)
      Result:
openjdk version "11.0.12" 2021-07-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7-LTS, mixed mode, sharing)

Add a Permanent Node

Login to Jenkins master and click Manage Jenkins -> Manage Nodes and Clouds. Click New Node. And then give the node a name (like linux-node), select Permanent Agent and click OK.

And then, click Save button. If you navigate to the node that you just created, you should see something like…

We will take copy this line.

java -jar agent.jar -jnlpUrl https://jenkins.hayato-iriumi.net/computer/linux%2Dnode/jenkins-agent.jnlp -secret 136fa14dcc4013727e24c9f1a9b84127d7c7ca0cfa15e22c1e1d4e0140122529 -workDir ""

Now, we’ll have to download agent.jar from the Jenkins master and upload the file to the slave machine. Just click on the agent.jar link to download it.

I have the agent.jar file in Downloads directory, so here is the command to upload the agent.jar file to the slave machine.

scp ./Downloads/agent.jar hiriumi@192.168.1.29:~

Now, ssh into the slave machine.

ssh hiriumi@192.169.1.29

Trust SSL Certificate

If your Jenkins master has SSL implemented, it’s a good practice to trust the SSL certificate. Here is how you can download the certificate on your slave machine.

openssl s_client -showcerts -connect jenkins.hayato-iriumi.net:443 < /dev/null | openssl x509 -outform DER > jenkins.hayato-iriumi.net.cer

Now use keytool to trust it.

sudo keytool -trustcacerts \
-keystore "/etc/java/java-11-openjdk/java-11-openjdk-11.0.12.0.7-0.el8_4.x86_64/lib/security/cacerts" \
-storepass changeit -alias jenkins -import -file \
"/home/hiriumi/jenkins.hayato-iriumi.net.cer"

Create a Script File and Execute

Paste the Java command you get from the node page in to slave.sh

java -jar agent.jar \
-jnlpUrl https://jenkins.hayato-iriumi.net/computer/linux%2Dnode/jenkins-agent.jnlp \
-secret 136fa14dcc4013727e24c9f1a9b84127d7c7ca0cfa15e22c1e1d4e0140122529 -workDir "./slave"

Make sure slave.sh is executable by adding execute flag on the file.

chmod +x slave.sh

If you execute the slave.sh file, it starts to communicate with the Jenkins master and starts to serve as one of the Jenkins slave.

./slave.sh

Once the connection is successful, you will see something like the following.

Now, this method does not survive restarting the slave machine. Now that the communication is successful, I will look into making this script a daemon.

How to Install VLC on Oracle Linux 8

VLC is an essential software to play any video files. I use it on all the computers that I use. Oracle Linux 8 does not have VLC by default, so here is the way to install VLC.

sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf install https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm
sudo dnf install vlc

Enjoy!

Installing JetBrains Products on Oracle Linux 8

I am trying to configure Oracle Linux 8 as my spare laptop. I need to install JetBrains products on it. I tried to install JetBrains Toolbox but it wouldn’t work. It’s packaged as AppImage file, so it should be pretty easy but when I execute it, a blank white window shows up and disappears.

So I looked for an alternative way to install JetBrains products. I installed snapd on it with the following command.

sudo dnf install snapd

Then, I searched for the JetBrains products like the following.

snap search jetbrains

Result:

Name                       Version   Publisher   Notes    Summary
pycharm-community          2021.2.2  jetbrains✓  classic  PyCharm Community Edition
phpstorm                   2021.2.3  jetbrains✓  classic  PhpStorm
pycharm-professional       2021.2.2  jetbrains✓  classic  PyCharm Professional Edition
intellij-idea-community    2021.2.3  jetbrains✓  classic  Capable & Ergonomic Java IDE
intellij-idea-ultimate     2021.2.3  jetbrains✓  classic  Capable & Ergonomic Java IDE for Enterprise, Web & Mobile Development
webstorm                   2021.2.2  jetbrains✓  classic  WebStorm
datagrip                   2021.2.4  jetbrains✓  classic  DataGrip
clion                      2021.2.3  jetbrains✓  classic  A cross-platform IDE for C and C++
pycharm-educational        2021.2.2  jetbrains✓  classic  Easy and Professional Tool to Learn & Teach Programming with Python
rubymine                   2021.2.3  jetbrains✓  classic  The Most Intelligent Ruby and Rails IDE
space                      2021.2.0  jetbrains✓  -        Desktop Application for JetBrains Space
rider                      2021.2.2  jetbrains✓  classic  A fast & powerful cross-platform .NET IDE
goland                     2021.2.3  jetbrains✓  classic  GoLand
intellij-idea-educational  2021.2.2  jetbrains✓  classic  IntelliJ IDEA Educational Edition
kotlin                     1.5.31    jetbrains✓  classic  Command line Kotlin compiler

The first application I want to install is PyCharm, so I ran the following command to install it.

snap install pycharm-professional

If you search pycharm in your GNOME UI, you will be able to start to use it.

I still would like to use JetBrains’ Toolbox so I posted my question in their support forum to resolve

Before I posted it, I did a fair bit of research. Toolbox is packaged as AppImage, so you can check the command options like the following.

./jetbrains-toolbox --appimage-help

I learned that you can even extract files from the image like the following.

./jetbrains-toolbox --appimage-extract

I did digging into the extracted files but I could not find a solution for it. Oh well, I can use JetBrains’ products anyway, so I’m happy for now.