Working of Slave in Jenkins !!!

KUSHAGRA BANSAL
4 min readOct 29, 2020

--

Prerequisite:

1. Jenkins and maven Setup.

2. Must know how to make a maven project.

3. About Git and GitHub.

Links: https://github.com/kushagra67414/lab5.git

Note: If Jenkins shows an invalid user name or not able to access it.

Type: Jenkins.exe stop

It will stop all of Jenkins's services.

Then start your Jenkins using :

Java –jar Jenkins.war

Step-1:

Go to “manage Jenkins> Configure Global Security >”

Goto agent property option and select the “random” option. In further, this “random” concept is being explained.

Step-2:

Go to “manage Jenkins > Manage Nodes”

Create a new node say “Slave_1”

Give description name (anything) say Slave_exp

Configurations we have to do :

1. Remote Root Directory: create a folder In local machine say “jenkins_slave_1” and give the path of the folder in it.

It will act as a workspace where our slaves will be stored.

2. Usage option: Select “Use this node as much as possible”.

3. Launch method: Select “Launch agend by connecting it to the master”. This option will we occur if you have chosen the “Random” option earlier in your configuration file.

4. Custom WorkDir path: the path of your workspace folder. [ same as Remote Root Directory ]

Save the configurations

Step-3:

Now Slave is created but it is not connected to the master.

So click on the Slave_1

Click on the agent.jar, it will download the file as it helps to activate or launch the agent on the command line.

Download it and create a folder at the local machine and save it to that Folder

Folder name lets say: “Jenkins_slave_agent”

Step-4:

java -jar D:\cicd\Jenkins_slave_agent\agent.jar -jnlpUrl http://localhost:8080/computer/Slave_1/slave-agent.jnlp -secret 5058cb83cf38812a244b3bfdcf3f6a5cbd9fd75ce75e4002200fce804c76b5b7 -workDir “D:\cicd\jenkins_slave03”

Type will connect node to its master node.Refresh you will see slave is connected to its master node.
After the node is connect u will see RED CROSS LOGO is disappear.

Step-5:

Create a Github repo and push a maven project.

Create a project in Jenkins and configure it by giving GitHub repo path

https://github.com/kushagra67414/lab5.git ( Source code of the maven project)

As mentioned in Screenshots.

A.

B.

C. In Goals and Option: “mvn clean” used this command too.

Step-6:

Now we have to link it with the Slave_1 we have created

Goto “general” Selects Restrict where the project can be run and type the Slave project name.

Save your all configurations and Build the project.

A.

Step-7:

Click on Console output and check to build is successful or not. If not check your configurations file and correct it. Our project will save in our workspace directory on our local machine. In our Earlier configuration, we use Maven Clean Goal.

A. OutPut

B. Here your project gets stored in Slave.

Thank You !!!

Kushagra Bansal

--

--

No responses yet