Running WSL as a Node for Windows Jenkins Installation
Jenkins is a popular open-source automation server that allows developers to automate various tasks such as building, testing, and deploying software applications. It is widely used by software development teams to automate their software delivery pipeline. In this article, we will discuss how to run Linux Windows Subsystem for Linux (WSL) as a slave node from a Windows master node to run Jenkins.
Running Jenkins in WSL instead of creating a new server is a good option, especially for developers who are just learning and do not want to spend much on server costs. The first thing we need to do is install Jenkins on the Windows operating system. As you can imagine, it's a straightforward installation. One main requirement for running Jenkins is the availability of Java Development Kit (JDK) in your system.
First, we need to create an SSH key pair on the Windows master node. You can open PowerShell and run the following command:
ssh-keygen
It will ask for the details of the private key public key and will show you the location in which it will be stored.
Now, we can open WSL and check if it has Java installed by running the following command:
java --version
If Java is not installed, you can install it using your distribution's package manager. Once Java is installed, we need to create a new user for the purpose of Jenkins. However, for this example, we will be sticking with the user 'xavi'. You need to add the previously created public SSH key to the /home/xavi/.ssh/authorized_keys file.
Next, we need to test the SSH connection through normal SSH. Before that, we need to identify the IP address of WSL using the following command:
ifconfig
For our case, it's 172.23.224.33, which is a private IP address. To connect from Windows to WSL, we need to run the following command:
service ssh start
For passwordless login, we need to add windows public SSH key to /home/xavi/.ssh/authorized_keys file.
Once done that,We can open powershell from windows and test it's working via following command.
ssh xavi@172.23.224.33
Now, let's go ahead and add the WSL node to the Jenkins master node. Follow the below steps:
- Login to the Jenkins master node.
- Click on "Manage Jenkins" on the left-hand side menu.
- Click on "Manage Nodes and Clouds".
- Click on "New Node".
- Enter a name for the new node, and select "Permanent Agent".
- Click on "OK".
- On the configuration page, enter the following details:
- Remote root directory: /home/xavi
- Launch method: Launch agent via SSH
- Host: 172.23.224.33
- Credentials: Add new SSH credential with the private key generated on the master node
- Host Key Verification Strategy: Non verifying Verification Strategy
- SSH Port: 22
- Click on "Save".
In conclusion, running Jenkins in WSL is a great option, especially for developers who are just starting and do not want to spend much on server costs. With the above steps, you can easily set up WSL as a slave node from a Windows master node to run Jenkins.
Comments
Post a Comment