Understanding Jenkins: Projects, Users, and Architecture

Understanding Jenkins: Projects, Users, and Architecture

In the last publish, we looked at the principles of CI/CD (Continuous Integration and Continuous Delivery) pipelines and the importance that Jenkins plays in automating software development processes. If you haven't read it yet, you might want to start with the overview below:

"Jenkins and CI/CD pipeline"

Overview of the Previous Article

What is the CI/CD Pipeline?

A CI/CD pipeline automates code integration, testing, and deployment, resulting in a more consistent and dependable software development process.

Challenges with Traditional Development Workflow

We looked at the manual processes in standard development and the problems that might occur, such as delayed integration, testing discrepancies, and deployment obstacles.

CI/CD Pipeline's Solutions

The article explained how CI/CD pipelines overcome the difficulties of manual development by automating procedures, resulting in quicker, more reliable, and error-free development.

Benefits of Using CI/CD Pipeline

The benefits of CI/CD were highlighted, including frequent integration, automated testing, continuous deployment, more cooperation, and greater productivity.

Let's take a look at Jenkins, an open-source automation server used to orchestrate CI/CD pipelines.

What is Jenkins?

Jenkins automates code development, testing, and deployment, serving as a centralized platform for efficient CI/CD pipeline management.

Solving CI/CD Management Challenges

Learning how Jenkins handles the issues of controlling and automating CI/CD pipelines, decreasing manual involvement, and minimizing mistakes.

Impact of Jenkins on CI/CD

Jenkins speeds the development lifecycle by guaranteeing consistent and reliable builds, tests, and deployments.

Build Source Code Polling

Introduced the idea of building source code polling, which automates the integration and testing of the most recent version of software.

Note: For a detailed understanding, refer to the full article on CI/CD Pipelines and Jenkins Automation.


Linked project in Jenkins

A connected project allows you to reference another project and access its artefacts or other resources. This can be handy for building pipelines that span numerous projects or sharing common resources between them.

There are two primary methods for linking projects in Jenkins:

  1. The "Build Other Projects" phase allows you to initiate the execution of another project. To utilise this step, enter the name of the project you wish to trigger. Once you've provided the project name, you may set the step to wait for the project to finish before proceeding.

  2. Using the "Copy Artefacts" plugin: This plugin allows you to copy artefacts from one project into another. To utilise this plugin, first install it in your Jenkins instance. Once the plugin is installed, you may transfer artefacts from one project to another by selecting the "Copy Artefacts" step in the pipeline for the project from which you wish to receive the artefacts.

Upstream project and downstream project linkage

Jenkins provides us with two ways in which we can link projects and trigger them.

  1. Upstream Project: The project that triggers other projects.

  2. Downstream Project: The project that is triggered by the upstream project.

For example, we can have a build job as the upstream project, and when it is completed successfully, we may start a deployment process as the downstream project.

+-------------------+       +-----------------------+
| Upstream Pipeline |       | Downstream Pipeline   |
|                   | ----> |                       |
|    Build Stage    |       |     Deploy Stage      |
+-------------------+       +-----------------------+

Use Management in Jenkins

User management in Jenkins is the process of creating, setting, and managing user accounts and permissions in the Jenkins system. It includes limiting access to Jenkins resources, creating roles, and granting rights to people depending on their duties. It is critical for Jenkins security, traceability, and accountability.

Jenkins provides a basic security configuration in which the first user-generated upon installation is granted administrator privileges. While the first user has complete control, all subsequent users created later are granted administrative capabilities by default.

Plugins such as "Role-based Authorization Strategy" can be used to establish finer-grained control over user permissions, including the ability to restrict permissions for certain individuals or groups. This plugin allows you to create roles with particular permissions and assign them to persons or groups.

Let's learn about Jenkins' master-slave architecture.

Master-Slave Architecture

Jenkins' master-slave design, also known as Jenkins Distributed Builds, enables you to split the workload across numerous computers (nodes) to increase build and deployment efficiency. This design includes a central Jenkins server, known as the master, and many agent computers, known as slaves. The master is in charge of scheduling and overseeing build tasks, while the slaves carry them out. Slaves may operate on a variety of operating systems, allowing you to develop and test applications across several platforms.

+----------------------+
|   Jenkins Master     |
|                      |
|  +----------------+  |
|  | Jenkins Agent  |  | 
|  |   (Slave)      |  |
|  |                |  |
|  +----------------+  |
|                      |
|  +----------------+  |
|  | Jenkins Agent  |  |
|  |   (Slave)      |  |
|  |                |  |
|  +----------------+  |
|                      |
+----------------------+

Example

Consider this scenario: a software development team is working on a project with several components. The team has a master Jenkins server and many build machines devoted to various tasks:

  • Build Server: A specialized computer with a strong CPU and enough memory to swiftly compile and create code

  • Test Server: A test server is a system equipped with appropriate testing tools and configurations for executing automated tests.

  • Deployment Server: A deployment server is a system that is configured to deliver software to various environments.

    .

Key Aspects of User Management in Jenkins:

User Accounts

Jenkins creates user accounts for anyone who interacts with it. Each user account has a unique username and authentication credentials.

Roles

Roles define a set of permissions that limit the actions a user may conduct inside Jenkins. Roles are frequently connected with specific tasks or job activities (for example, administrator, developer, and tester).

Permissions

Permissions indicate which activities users are permitted to execute (for example, build, configure, and remove). Permissions are allocated to roles, which are then assigned to users.

Security Realms

Jenkins supports many security domains for user authentication, including LDAP, Active Directory, and its user database.

+-------------------------+
|     Jenkins Server      |
|                         |
|   +-----------------+   |
|   | User Management |   |
|   |                 |   |
|   |   +-----------+ |   |
|   |   |   Roles   | |   |
|   |   +-----------+ |   |
|   |   |           | |   |
|   |   |Permissions| |   |
|   |   |           | |   |
|   +---|-----------|-+   |
|       |   Users   |     |
+-------|-----------|-----+
        | Security  |
        |  Realms   |
        +-----------+

Real-Life Example and Use in CI/CD Pipeline

Jenkins supports many security domains for user authentication, including LDAP, Active Directory, and its own user database.Consider a software development team that utilises Jenkins to automate its continuous integration and delivery workflow. The Jenkins instance used by the team is set to employ role-based access control (RBAC), which implies that users are allocated distinct roles with varied permissions. For example:

  • Developers:

    • Developers must access to initiate builds and check build status.

    • They are allocated a "Developer" position with the necessary rights.

  • Testers:

    • Testers need access to deploy and test apps.

    • They are allocated the "Tester" position, which includes deployment job rights.

  • Administrators:

    • Jenkins administrators require complete control over Jenkins setups.

    • They are given the "Administrator" job with wide rights.

How User Management is Used in CI/CD Pipelines

User management is used in CI/CD pipelines to control access to sensitive data, such as code deployment to production. For example, only approved individuals should be able to approve deployments and launch production builds. User management can also be used to enforce restrictions, such as requiring two-factor authentication for all users with permission to authorize deployments.

Benefits of User Management

User management can help prevent unauthorised access to Jenkins and safeguard critical data. It can also be useful to manage who can undertake sensitive tasks, such as authorising deployments. User management may also help you track who has accessed Jenkins and what actions they have taken.