Introduction
Jenkins is a powerful open-source automation server used to build, test, and deploy software in a continuous integration/continuous deployment (CI/CD) pipeline. In a typical Jenkins setup, jobs are orchestrated by a master node and distributed to various agents, allowing for flexible builds across different environments.
This story will walk you through the basic Jenkins architecture, outlining each component’s role and how they contribute to automating the build and deployment process.
1. Organization User
At the top of this architecture is the Organization User, the individual or team responsible for making changes to the codebase. These changes trigger the Jenkins build process.
2. Source Code Repository
The source code is managed in a Source Code Repository, typically using a version control system (VCS) like Git. Jenkins is integrated with the repository through SCM (Source Code Management), allowing it to monitor changes (commits or merges). Once a change is detected, Jenkins pulls the latest version of the code to begin the build process.
3. Master Node (Controller)
The Master Node, also known as the Controller, is the brain of the Jenkins architecture. It schedules build jobs, monitors the agents (slave nodes), and assigns jobs based on predefined rules. The master node doesn’t usually execute the build or test jobs but instead delegates them to agents that are better suited for those tasks.
4. Slave Nodes (Agents)
Jenkins can distribute workloads across various Slave Nodes (Agents). Each agent is a machine (physical or virtual) that performs the actual work. In the diagram above, we have three different types of agents:
- Agent1: A Windows-based machine that handles Windows-specific jobs.
- Agent2: A Linux-based machine for running jobs in Linux environments.
- Agent3: A MacOS machine, used when builds or tests require a Mac environment.
The communication between the master node and the agents is typically established via SSH or JNLP.
5. Build, Test, Deploy
Once the agents receive jobs from the master, they proceed with the Build, Test, and Deploy stages:
- Build: The source code is compiled, and build artifacts are created.
- Test: Automated tests are run to ensure the build is stable and free of defects.
- Deploy: If the build and tests pass, the application can be deployed to staging or production environments.
The ability to run jobs on different agents allows for greater flexibility and efficiency, especially in large projects with varying platform requirements.
Conclusion
This basic Jenkins architecture highlights the power of distributed builds and how Jenkins can streamline the CI/CD process across different platforms. Whether you’re building software on Windows, Linux, or MacOS, Jenkins can coordinate and automate these tasks, reducing manual work and minimizing errors.
If you’re looking to implement Jenkins in your organization, understanding this architecture will help you set up a robust and scalable CI/CD pipeline.