Lab 5.1 - Distributed Jenkins Builds

1. Configuring SSH. Do it on the master node

ssh root@10.X.X.66
su - jenkins

ssh-keygen -t rsa
cat .ssh/

2. Install Java Development Kit 11 and save the public key of master node on slave node

ssh root@10.X.X.67
sudo apt install openjdk-11-jdk
java -version
useradd -m -s /bin/bash jenkins
su - jenkins
mkdir .ssh/
cat << EOF >> .ssh/authorized_keys
[Paste the public key here]

3. Try to SSH from master to slave node using jenkins user

ssh jenkins@10.X.X.67

4. Go to Jenkins Dashboard > Manage Jenkins

5. And then click Manage Nodes and Clouds

6. To add a new node, click New Node button

7. Identify it with the following values:

  • Name: podX-slave0
  • Type: Permanent Agent

Click OK

8. Configure the slave node with these properties:

  • Number # of executors: 2
  • Remote root directory: /home/jenkins
  • No Labels
  • Usage: Use this node as much as possible
  • Launch method: Launch slave agents via SSH and configure it with:
    • Host: 10.X.X.67

For credentials, click Add > Jenkins:

  • Domain: Global Credentials (unrestricted)
  • Kind: SSH Username with private key
  • Username: jenkins
  • Private Key: Enter directly and paste the private key of user jenkins in master node (you can retrieve from id_rsa file on folder .ssh/ which generated before)
  • Passphrase: None and then click Add

  • Set the Credentials field dropdown to Jenkins (SSH Key for the Agent)
  • Click the button Advanced to access the Port field, and set it to 22
  • Host Key Verification Strategy: No verifying verification strategy
  • Under the Node Properties, check the toggle for Environment Variables
  • Click Add to add a new environment variable
  • Enter JAVA_HOME for Name and /usr/lib/jvm/java-11-openjdk-amd64/ for value

Click Save

9. Click the Node podX-slave0 on the list

10. On the left-menu, click on the Log

11. See that, if you read the log, the agent is now online