How to dynamically provision our Slave Node?

Jaindivya
4 min readMar 25, 2021

Step-1:-First of all check the IP of docker engine and docker should be installed in the base OS

Step-2 : Start the Jenkins Cluster and install the docker plugin inside it.

Step-3 : The Docker plugin is installing…

Step-4 : check the status of Docker and go inside the docker systemd file

Step-5: Inside the systemd file add the protocol tcp with the IP and the port no.So as to allow outside users to access the docker.This concept is called socket binding.

Step 6: Save the file and as we changed something in the systemd file,we have to reload it by using systemctl daemon-reload and restart your docker services

As we can see below,the status of docker shows the tcp we added

Step 7:Finally, we have to do the connectivity..

I want my master to go to docker and when the need comes launch the instance . In the Jenkins perspective this concept is called Cloud configure

Step 8:Write the docker host URL and check the connectivity,but as we can see the connection lost…To regain the connection we have to stop the firewall in the docker engine by using the following command:

**systemctl stop firewalld**

Now check the connection..everything is all good to go

Step 9: Go to docker template and give a label to your slave node and in the docker image give the image in which you have configured everything.

In this image we have the maven setup..

Step 10: In the build ..invoke top level maven targets write your goals,like what we want to do with our code

1>Compile it ,(Basically in case of maven we use mvn copile command.But inside docker it is already inbuilt)

2>test it

3>Create a final package

Now make sure you have github plugin installed in jenkins and add the code which you want to clone..in the repository URL

Click on build Now ….Your jenkins will start your job for you

In the workspace we have got all our necessary folders

Voila! It is successfully finished

Now,After job has been successfully finished the node is removed and no workspace is there in our Jenkins which helps us to save a lot of space of our ram…

To get the jar file even after the job is finished in our master, we need

to add a post build actions as shown below:

This is how we get our jar file even after dynamic allocation of node is done and removed…This file can be accessed anytime in jenkins

Hope it helps!!

_DIvya

--

--