Master-Slave Architecture of Jenkins and its Working

jenkins logo
Reading Time: 2 minutes

What is Jenkins?

Jenkins is an open-source CI/CD tool that is java based.

We use Jenkins because:

  • Jenkins continuously builds and tests the project so the developers can easily integrate the changes in the code, that is, CI (Continuous Integration)
  • Using Jenkins Pipeline to continuously deliver and deploy the application, that is, CD (Continuous Delivery)

Jenkins Architecture

Jenkins performs distributed build using a Master-Slave Architecture. Now let’s take a look at the diagram, which represents the following three components:

Source Code Repository-

Master-

The main Jenkins Server is the Master Server of Jenkins. This acts as a control server that arranges the defined workflow of the pipeline. The jobs of this Master are as follows:

  • scheduling jobs
  • sending builds to slaves to execute the job
  • keeping track of the slaves states (online/offline)
  • can also directly execute build jobs

Slave-

The slave is a part of the Jenkins environment that runs on a remote environment. The characteristics of slaves include:

  • it listens to the Master instance
  • it’s job is to do as they are told to, that includes executing build jobs conveyed by the Master

Working of Jenkins Architecture

This architecture works in following steps:

1. The developer commits the changes in the source code repository

2. The CI server of Jenkins then checks the repository and pulls the newly changed code at regular

intervals.

3. The build server builds the pulled code into an executable file. Feedback is sent to the developers

in case of failure of the build.

4. Jenkins deploys the build application on the test server. The developers are alerted if it fails.

5. If the tests are successful and the code is error-free, the tested application is deployed on the production server.

In some cases, files may have different code and require multiple builds and the Jenkins server cannot handle multiple builds simultaneously for this, the Master distributes the workload and allows us to run different builds on different environments each called a Slave.

knoldus