DEV Community

Cover image for Jenkins Deep Dive: Mastering Linked Projects, User Management, and Architecture
Sushant Gaurav
Sushant Gaurav

Posted on • Updated on

Jenkins Deep Dive: Mastering Linked Projects, User Management, and Architecture

Jenkins Deep Dive: Mastering Linked Projects, User Management, and Architecture

In the previous article, we explored the fundamentals of CI/CD (Continuous Integration and Continuous Delivery) pipelines and the pivotal role that Jenkins plays in automating software development processes. If you haven't read it yet, you may find it helpful to start with the overview below:

"Understanding CI/CD Pipelines and Jenkins Automation"

Overview of the Previous Article

What is the CI/CD Pipeline?

A CI/CD pipeline automates code integration, testing, and deployment, ensuring a consistent and reliable software development process.

Challenges with Traditional Development Workflow

We examined the manual steps in traditional development and the issues that arise, such as delayed integration, testing inconsistencies, and deployment challenges.

CI/CD Pipeline's Solutions

The article discussed how CI/CD pipelines address the problems of manual development by automating processes, leading to faster, more reliable, and less error-prone development.

Benefits of Using CI/CD Pipeline

Highlighted the advantages of CI/CD, including frequent integration, automated testing, continuous deployment, increased collaboration, and improved efficiency.


Now, let's delve into Jenkins, the open-source automation server that plays a key role in orchestrating CI/CD pipelines.

What is Jenkins?

Jenkins automates building, testing, and deploying code, providing a central platform for managing the CI/CD pipeline efficiently.

Solving CI/CD Management Challenges

Explored how Jenkins addresses the challenges of managing and automating CI/CD pipelines, reducing manual intervention, and minimizing errors.

Impact of Jenkins on CI/CD

Discussed how Jenkins accelerates the development lifecycle, ensuring consistent and reliable builds, tests, and deployments.

Build Source Code Polling

Introduced the concept of build source code polling, which helps automate the integration and testing of the latest 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 linked project is a way to reference another project and use its artifacts or other resources. This can be useful for creating pipelines that span multiple projects, or for sharing common resources between projects.

There are two main ways to link projects in Jenkins:

  1. Using the "Build Other Projects" step: This step allows you to trigger the execution of another project. To use this step, you will need to specify the name of the project that you want to trigger. Once you have specified the project name, you can configure the step to wait for the project to complete before continuing.
  2. Using the "Copy Artifacts" plugin: This plugin allows you to copy artifacts from one project to another. To use this plugin, you will need to install it in your Jenkins instance. Once the plugin is installed, you can copy artifacts from one project to another by clicking on the "Copy Artifacts" step in the pipeline for the project in that you want to receive the artifacts.

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 successfully builds, we can trigger a deployment job as a downstream project.

+-------------------+       +-----------------------+
| Upstream Pipeline |       | Downstream Pipeline   |
|                   | ----> |                       |
|    Build Stage    |       |     Deploy Stage      |
+-------------------+       +-----------------------+
Enter fullscreen mode Exit fullscreen mode

Use Management in Jenkins

User management in Jenkins refers to the process of creating, configuring, and managing user accounts and permissions within the Jenkins environment. It involves controlling access to Jenkins resources, defining roles, and assigning permissions to users based on their responsibilities. It is crucial for maintaining security, traceability, and accountability in Jenkins.

By default, Jenkins comes with a simple security setup where the initial user created during installation is granted administrative rights. While this initial user has full control, additional users added later also receive administrative privileges by default.

To implement more fine-grained control over user permissions, including the ability to restrict permissions for specific users or groups, you can use plugins like "Role-based Authorization Strategy." This plugin allows you to define roles with specific sets of permissions and assign those roles to users or groups.

Jenkins follows a master-slave architecture, let's learn about it.

Master-Slave Architecture

In Jenkins, the master-slave architecture, also known as Jenkins Distributed Builds, allows you to distribute the workload across multiple machines (nodes) to improve build and deployment efficiency. In this architecture, there is a central Jenkins server, known as the master, and multiple agent machines, known as slaves. The master is responsible for scheduling and managing build jobs, while the slaves are responsible for executing the actual build jobs. Slaves can run on different operating systems, enabling you to build and test software on various platforms.

+----------------------+
|   Jenkins Master     |
|                      |
|  +----------------+  |
|  | Jenkins Agent  |  | 
|  |   (Slave)      |  |
|  |                |  |
|  +----------------+  |
|                      |
|  +----------------+  |
|  | Jenkins Agent  |  |
|  |   (Slave)      |  |
|  |                |  |
|  +----------------+  |
|                      |
+----------------------+
Enter fullscreen mode Exit fullscreen mode

Example

Consider a scenario in which a software development team is working on a project with multiple components. The team has a master Jenkins server and several build machines dedicated to different tasks:

  • Build Server: A dedicated machine with a powerful CPU and ample memory for compiling and building code quickly.
  • Test Server: A machine with specific testing tools and configurations for running automated tests.
  • Deployment Server: A machine configured for deploying applications to different environments.

Key Aspects of User Management in Jenkins:

User Accounts

User accounts are created for individuals who interact with Jenkins. Each user account has a unique username and associated credentials for authentication.

Roles

Roles define a set of permissions that determine what actions a user can perform within Jenkins. Roles are often associated with specific responsibilities or job functions (e.g., admin, developer, tester).

Permissions

Permissions specify the actions users are allowed to perform (e.g., build, configure, delete). Permissions are assigned to roles, and roles are assigned to users.

Security Realms

Jenkins supports different security realms for user authentication, such as LDAP, Active Directory, or its internal user database.

+-------------------------+
|     Jenkins Server      |
|                         |
|   +-----------------+   |
|   | User Management |   |
|   |                 |   |
|   |   +-----------+ |   |
|   |   |   Roles   | |   |
|   |   +-----------+ |   |
|   |   |           | |   |
|   |   |Permissions| |   |
|   |   |           | |   |
|   +---|-----------|-+   |
|       |   Users   |     |
+-------|-----------|-----+
        | Security  |
        |  Realms   |
        +-----------+
Enter fullscreen mode Exit fullscreen mode

Real-Life Example and Use in CI/CD Pipeline

Consider a software development team that uses Jenkins to automate their CI/CD pipeline. The team's Jenkins instance is configured to use role-based access control (RBAC), which means that users are assigned different roles with different permissions. For example:

  • Developers:
    • Developers need permission to trigger builds and view build status.
    • They are assigned a "Developer" role with appropriate permissions.
  • Testers:
    • Testers require permission to deploy and test applications.
    • They are assigned a "Tester" role with permissions for deployment jobs.
  • Administrators:
    • Jenkins administrators need full control over Jenkins configurations.
    • They are assigned an "Administrator" role with extensive permissions.

How User Management is Used in CI/CD Pipelines

User management is used in CI/CD pipelines to control who can access and perform sensitive actions, such as deploying code to production. For example, only authorized users should be able to approve deployments and trigger production builds. User management can also be used to enforce policies, such as requiring two-factor authentication for all users who can approve deployments.

Benefits of User Management

User management can help to prevent unauthorized access to Jenkins and protect sensitive data. It can also help to control who can perform sensitive actions, such as approving deployments User management can also help to track who has accessed Jenkins and what actions they have performed.

Top comments (0)