{"id":466,"date":"2024-07-15T00:26:00","date_gmt":"2024-07-15T00:26:00","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=466"},"modified":"2024-07-15T00:26:00","modified_gmt":"2024-07-15T00:26:00","slug":"jenkins-architecture-explained","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=466","title":{"rendered":"Jenkins Architecture Explained &#8211; Beginners Guide To Jenkins Components"},"content":{"rendered":"<p>This blog covers the fundamental Jenkins architecture and its related components. If you are a beginner in Jenkins, it will help you understand how Jenkins components work together and the key configurations involved.<\/p>\n<h2 id=\"what-is-jenkins\">What is Jenkins?<\/h2>\n<p>Jenkins is an easy-to-use open-source java-based <a href=\"https:\/\/devopscube.com\/continuous-integration-delivery-deployment\/\" rel=\"noreferrer noopener\">CI\/CD<\/a> tool. It has been around for some time, and several organizations use it for their CI\/CD needs.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-grey\">\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">Important Note:<\/strong><\/b> It is essential to have an understanding of Continuous integration &amp; continuous delivery to understand Jenkins better.<\/div>\n<\/div>\n<p>Jenkins has huge community support and an ocean of plugins that can integrate with many open-source and enterprise tools to make your life so easy.<\/p>\n<p>Despite the growing popularity of CI\/CD tools like GitLab CI and GitHub Actions, which are increasingly being adopted by organizations for their CI\/CD needs, Jenkins remains widely used in many organizations.<\/p>\n<p>As per the <a href=\"https:\/\/www.jetbrains.com\/lp\/devecosystem-2023\/team-tools\/?ref=devopscube.com\" rel=\"noreferrer noopener\">Developer Ecosystem Report<\/a>, 54% of the developers use Jenkins for CI\/CD.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-38-12.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"520\" height=\"605\"><\/figure>\n<p>Jenkins is commonly used for the following.<\/p>\n<ol>\n<li>Continuous Integration for application and infrastructure code.<\/li>\n<li>Continuous delivery pipelines to deploy the application to different environments using <a href=\"https:\/\/devopscube.com\/jenkins-pipeline-as-code\/\" rel=\"noreferrer noopener\">Jenkins pipeline as code<\/a>.<\/li>\n<li>Infrastructure component deployment and management using <a href=\"https:\/\/devopscube.com\/infrastructure-as-code-configuration-management\/\">IaC<\/a> Tools..<\/li>\n<li>Run batch operations using Jenkins jobs.<\/li>\n<li>Run ad-hoc operations like backups, cleanups, remote script execution, event triggers, etc.<\/li>\n<li>Jenkins Architecture<\/li>\n<\/ol>\n<p>The following diagram shows the overall architecture of Jenkins and the connectivity workflow..<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/jenkins-architecture-1.gif\" class=\"kg-image\" alt=\"Jenkins Architecture and workflow\" loading=\"lazy\" width=\"776\" height=\"874\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/jenkins-architecture-1.gif 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/jenkins-architecture-1.gif 776w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Following are the key components in Jenkins<\/p>\n<ol>\n<li>Jenkins Master Node<\/li>\n<li>Jenkins Agent Nodes\/Clouds<\/li>\n<li>Jenkins Web Interface<\/li>\n<\/ol>\n<p>Let&#8217;s look at each component in detail.<\/p>\n<h2 id=\"jenkins-server-formerly-master\">Jenkins Server (Formerly Master)<\/h2>\n<p>Jenkins&#8217;s server or master node holds all key configurations. Jenkins master server is like a control server that orchestrates all the workflow defined in the pipelines. For example, scheduling a job, monitoring the jobs, etc.<\/p>\n<p>Let&#8217;s have a look at the key Jenkins master components.<\/p>\n<h3 id=\"jenkins-jobs\">Jenkins Jobs<\/h3>\n<p>A job is a collection of steps that you can use to build your source code, test your code, run a shell script, run an Ansible role in a remote host or execute a terraform play, etc. We normally call it a <a href=\"https:\/\/devopscube.com\/jenkins-pipeline-as-code\/\" rel=\"noreferrer noopener\">Jenkins pipeline<\/a>.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-27-17.png\" class=\"kg-image\" alt=\"Jenkins job steps\" loading=\"lazy\" width=\"398\" height=\"285\"><\/figure>\n<p>If you translate the above steps to a Jenkins pipeline job, it looks like the following.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-21-16.png\" class=\"kg-image\" alt=\"Jenkins pipeline job example.\" loading=\"lazy\" width=\"649\" height=\"357\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-21-16.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-21-16.png 649w\"><\/figure>\n<p>There are multiple job types available to support your workflow for continuous integration &amp; continuous delivery.<\/p>\n<h3 id=\"jenkins-plugins\">Jenkins Plugins<\/h3>\n<p>Plugins are official and community-developed modules that you can install on your Jenkins server. It helps you with more functionalities that are not natively available in Jenkins.<\/p>\n<p>For example, if you want to upload a file to s3 bucket from Jenkins, you can install an AWS Jenkins plugin and use the abstracted plugin functionalities to upload the file rather than writing your own logic in AWS CLI. The plugin takes care of error and exception handling.<\/p>\n<p>Here is an example, of s3 file upload functionality provided by the <a href=\"https:\/\/plugins.jenkins.io\/pipeline-aws\/?ref=devopscube.com\" rel=\"noreferrer noopener\">AWS Steps plugin<\/a><\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-23-21.png\" class=\"kg-image\" alt=\"Jenkins plugin config example.\" loading=\"lazy\" width=\"399\" height=\"324\"><\/figure>\n<p>You can install\/upgrade all the available plugins from the Jenkins dashbaord itselft. For corporate network, you will have to setup a proxy details to connect to the plugin repository.<\/p>\n<p>You can also download the plugin file and install it by copying it to the plugins directory under <code>\/var\/lib\/jenkins<\/code> folder.<\/p>\n<p>You can also develop your custom plugins. Check out all plugins from the <a href=\"https:\/\/plugins.jenkins.io\/?ref=devopscube.com\" rel=\"noreferrer noopener\">Jenkins Plugin Index<\/a><\/p>\n<h3 id=\"jenkins-global-security\">Jenkins Global Security<\/h3>\n<p>Jenkins has the following type of primary authentication methods.<\/p>\n<ol>\n<li><strong>Jenkins&#8217;s own user database:-<\/strong> Set of users maintained by Jenkins&#8217;s own database. When we say database, its all flat config files (XML files).<\/li>\n<li><strong>LDAP Integration<\/strong>:- Jenkins authentication using corporate LDAP configuration.<\/li>\n<li><strong>SAML Single Sign On(SSO)<\/strong>: Support single signon using providers like Okta, AzureAD, Auth0 etc..<\/li>\n<\/ol>\n<p>With Jenkins matric-based security you can further assign roles to users on what permission they will have on Jenkins.<\/p>\n<h3 id=\"jenkins-credentials\">Jenkins Credentials<\/h3>\n<p>When you set up Jenkins pipelines, there are scenarios where it needs to connect to a cloud account, a server, a database, or an API endpoint using secrets.<\/p>\n<p>In Jenkins, you can save different types of secrets as a credential.<\/p>\n<ol>\n<li>Secret text<\/li>\n<li>Username &amp; password<\/li>\n<li>SSH keys<\/li>\n<\/ol>\n<p>All credentials are encrypted (AES) by Jenkins. The secrets are stored in <code>$JENKINS_HOME\/secrets\/<\/code> directory. It is very important to secure this directory and exclude it from Jenkins backups.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-grey\">\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">Note:<\/strong><\/b> Best practice is to use external secrets management solutions like <a href=\"https:\/\/devopscube.ghost.io\/setup-hashicorp-vault-beginners-guide\/?ref=devopscube.com\" rel=\"noreferrer noopener\">vault<\/a> instead of Jenkins native credentials.<\/div>\n<\/div>\n<h3 id=\"jenkins-nodesclouds\">Jenkins Nodes\/Clouds<\/h3>\n<p>You can configure multiple agent nodes (Linux\/Windows) or clouds (<a href=\"https:\/\/devopscube.com\/what-is-docker\/\" rel=\"noreferrer noopener\">docker<\/a>, kubernetes) for executing Jenkins jobs. We will learn more about it in the agent section.<\/p>\n<h3 id=\"jenkins-global-settings-configure-system\">Jenkins Global Settings (Configure System)<\/h3>\n<p>Under Jenkins global configuration, you have all the configurations of installed plugins and native Jenkins global configurations.<\/p>\n<p>Also, you can configure global environment variables under this section.  For example, you can store the tools (Nexus, Sonarqube, etc) URLs as global environment variables and use them in the pipeline. This way it is easier to make URL changes that get reflected in all the Jenkins jobs.<\/p>\n<h3 id=\"jenkins-logs\">Jenkins Logs<\/h3>\n<p>Provides logging information on all Jenkins server actions including job logs, plugin logs, webhook logs, etc.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-grey\">\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">Note:<\/strong><\/b> All the configurations for the above-mentioned components are present as a config file (XML file) in the Jenkins master nodes data directory.<\/div>\n<\/div>\n<h2 id=\"jenkins-agent\">Jenkins Agent<\/h2>\n<p>Jenkins agents are the worker nodes that actually execute all the steps mentioned in a Job. When you create a Jenkins job, you have to assign an agent to it. Every agent has a label as a unique identifier.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-25-15.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"641\" height=\"270\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-25-15.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-25-15.png 641w\"><\/figure>\n<p>When you trigger a Jenkins job from the master, the actual execution happens on the agent node that is configured in the job.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-grey\">\n<div class=\"kg-callout-text\"><b><strong style=\"white-space: pre-wrap;\">Note:<\/strong><\/b> You can run jobs in the Jenkins server without a Jenkins agent. In this case, master nodes acts as the agent. However, the recommended approach is to have a <a href=\"https:\/\/devopscube.com\/setup-agents-on-jenkins-2\/\" rel=\"noreferrer noopener\">Jenkins master-agent setup<\/a> for different job requirements so that you don&#8217;t end up corrupting the Jenkins server for any system-wide configuration changes required for a job.<\/div>\n<\/div>\n<p>You can have any number of Jenkins agents attached to a master with a combination of Windows, Linux servers, and even containers as build agents.<\/p>\n<p>Also, you can restrict jobs to run on specific agents, depending on the use case. For example, if you have an agent with java 8 configurations, you can assign this agent for jobs that require Java 8 environment.<\/p>\n<p>There is no single standard for using the agents. You can set up a workflow and strategy based on your project needs.<\/p>\n<h2 id=\"jenkins-server-agent-connectivity\">Jenkins server-agent Connectivity<\/h2>\n<p>You can connect a Jenkins master and agent in two ways<\/p>\n<ol>\n<li><strong>Using the SSH method:<\/strong> Uses the ssh protocol to connect to the agent. The connection gets initiated from the Jenkins master. Ther should be connectivity over port 22 between master and agent.<\/li>\n<li><strong>Using the JNLP method:<\/strong> Uses java JNLP protocol (<a href=\"https:\/\/docs.oracle.com\/javase\/tutorial\/deployment\/deploymentInDepth\/jnlp.html?ref=devopscube.com\" rel=\"noreferrer noopener\">Java Network Launch Protoco<\/a>l). In this method, a java agent gets initiated from the agent with Jenkins master details. For this, the master nodes firewall should allow connectivity on specified JNLP port. Typically the port assigned will be <code>50000<\/code>. This value is configurable.<\/li>\n<\/ol>\n<p>There are two types of Jenkins agents<\/p>\n<ol>\n<li><strong>Agent Nodes:<\/strong> These are servers (Windows\/Linux) that will be <a href=\"https:\/\/devopscube.com\/setup-agents-on-jenkins-2\/\" rel=\"noreferrer noopener\">configured as static agents<\/a>. These agents will be up and running all the time and stay connected to the Jenkins server. Organizations use custom scripts to shut down and restart the agents when is not used. Typically during nights &amp; weekends.<\/li>\n<li><strong>Agent Clouds:<\/strong> Jenkins Cloud agent is a concept of having <a href=\"https:\/\/devopscube.com\/docker-containers-as-build-agents-jenkins\/\" rel=\"noreferrer noopener\">dynamic agents<\/a>. Means, whenever you trigger a job, a agent gets deployed as a VM\/container on demand and gets deleted once the job is completed. This method saves money in terms of infra cost when you have a huge Jenkins ecosystem and continuous builds.<\/li>\n<\/ol>\n<p>The following image shows a high-level view of different types of agents and connectivity types.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/jenkins-agent-conneticity-1.gif\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"780\" height=\"891\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/jenkins-agent-conneticity-1.gif 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/jenkins-agent-conneticity-1.gif 780w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>You can refer to the following tutorials to understand more about Jenkins clouds.<\/p>\n<ol>\n<li><a href=\"https:\/\/devopscube.com\/docker-containers-as-build-slaves-jenkins\/\" rel=\"noreferrer noopener\">Docker container as build agents.<\/a><\/li>\n<li><a href=\"https:\/\/devopscube.com\/jenkins-build-agents-kubernetes\/\" rel=\"noreferrer noopener\">Setup Jenkins Build Agents on Kubernetes Pods<\/a><\/li>\n<\/ol>\n<h2 id=\"jenkins-data\">Jenkins Data<\/h2>\n<p>All the Jenkins data gets stored in the following folder location.<\/p>\n<div class=\"kg-card kg-callout-card kg-callout-card-grey\">\n<div class=\"kg-callout-text\">\/var\/lib\/jenkins\/<\/div>\n<\/div>\n<p>Data includes all jobs config files, plugins configs, secrets, node information, etc. It makes Jenkins migration very easy as compared to other tools.<\/p>\n<p>If you take a jook at \/var\/lib\/jenkins\/ you will find most of the configurations in xml format.<\/p>\n<p>It is essential to <a href=\"https:\/\/devopscube.com\/jenkins-backup-data-configurations\/\" rel=\"noreferrer noopener\">back up the Jenkins data<\/a> folder every day. For some reason, if your Jenkins server data gets corrupt, you can restore the whole Jenkins with the data backup.<\/p>\n<p>Ideally, when deploying Jenkins in production, a dedicated <strong>extra volume is attached<\/strong> to the Jenkins servers that hold all the Jenkins data.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-28-14.png\" class=\"kg-image\" alt=\"\" loading=\"lazy\" width=\"875\" height=\"595\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-28-14.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-28-14.png 875w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<h2 id=\"jenkins-web-interface\">Jenkins Web Interface<\/h2>\n<p><a href=\"https:\/\/devopscube.com\/jenkins-2-tutorials-getting-started-guide\/\" rel=\"noreferrer noopener\">Jenkins 2.0<\/a> introduced a very intuitive web interface called &#8220;<strong>Jenkins Blue Ocean<\/strong>&#8220;. It has a good visual representation of all the pipelines.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/jenkins-blue-ocean-1.png\" class=\"kg-image\" alt=\"Jenkins Blue ocean web interface\" loading=\"lazy\" width=\"1024\" height=\"512\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/jenkins-blue-ocean-1.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/jenkins-blue-ocean-1.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/jenkins-blue-ocean-1.png 1024w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>In this blog, I have explained Jenkins architecture and its key components.<\/p>\n<p>I personally like Jenkins for its huge community support, its extensive official and community documentation.<\/p>\n<p>I have written many <a href=\"https:\/\/devopscube.com\/jenkins-2-tutorials-getting-started-guide\/\" rel=\"noreferrer noopener\">Jenkins tutorials<\/a> from my experience. If you are pursuing a career as a <a href=\"https:\/\/devopscube.com\/become-devops-engineer\/\" rel=\"noreferrer noopener\">DevOps engineer<\/a>, this is one of the best DevOps tools to learn hands-on CI\/CD.<\/p>\n<p>You might be starting to learn Jenkins or have some doubts regarding its workflow.<\/p>\n<p>Either way drop a comment below.<\/p>\n<p>And if you want to learn about how GitLab handles CI\/CD internally, check out my detailed guide on <a href=\"https:\/\/devopscube.com\/gitlab-architecture\/\" rel=\"noreferrer\">GitLab Architecture.<\/a><\/p>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/jenkins-architecture-explained\/\" target=\"_blank\" rel=\"noopener noreferrer\">Jenkins Architecture Explained &#8211; Beginners Guide To Jenkins Components \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/jenkins-architecture-explained\/<\/p>\n","protected":false},"author":1,"featured_media":467,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-466","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=466"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/466\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/467"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}