Difference Between Jenkins Agent And Node
Last Updated :
11 Mar, 2024
Jenkins is a popular open-source tool to perform continuous integration and build automation. Jenkins has established itself as a go-to tool for automating the development process. Jenkins can distribute tasks across multiple machines or environments, which are often referred to as agents or nodes. While we sometimes use these terms interchangeably, they serve distinct purposes in the Jenkins ecosystem. In this article, we will be exploring the differences between Jenkins Agent and Node.
Jenkins Agent
A Jenkins agent, also referred to as a Jenkins slave, is a worker machine, or container, that connects to a Jenkins controller and executes tasks when directed by the controller. The agent section specifies where the entire pipeline or specific stage will execute in the Jenkins environment, depending on where the agent is placed. Agents are used to offload tasks from the Jenkins master; this makes possible parallel execution of jobs and scalability of the Jenkins infrastructure.
Example: You can think of Jenkins agents as specialized workers in a factory. In the factory, there is a control room (Jenkins Master) where production schedules are managed. When there is a need to assemble a product( run a building job), the control room assigns tasks to workers (agents) who may be working in different locations. Each worker executes their tasks independently, which allows multiple products to be assembled simultaneously.
Jenkins Node
A Jenkins node, also known as a Jenkins server, is any machine (physical or virtual) connected to the Jenkins network or the Jenkins environment. Node is capable of executing pipelines or jobs. Nodes provide computational resources and environments to execute Jenkins build jobs. Both controllers and agents are considered to be nodes.
Example: Imagine a network of offices in a company where every office has several employees to perform tasks. Similarly, in Jenkins, each office represents a node, and each node represents a machine that contributes resources to execute Jenkins tasks. As each department in an office has unique tools and expertise, each node can have its own set of tools and resources.
Differences between Jenkins Agent and Node
Aspect
| Jenkins Agent
| Jenkins Node
|
---|
Definition
| Jenkins Agent are the worker machines that execute tasks as directed by the Jenkins controller.
| Jenkins Nodes are any machine ( be it physical or virtual) connected to the Jenkins environment and capable of executing pipelines or jobs.
|
---|
Purpose
| Agents executes Jenkins tasks remotely.
| Nodes provide resources to execute Jenkins tasks.
|
---|
Relationship to Master
| Operates under the control of the Jenkins master.
| Includes Jenkins master and any agents.
|
---|
Configuration
| Configured as separate entities from the Jenkins master.
| Includes both master and connected agents.
|
---|
Scalability
| More agents can be added if required.
| Scales as the Jenkins environment grows.
|
---|
Resource Utilization
| Resources can be optimized for specified tasks.
| Node utilizes resources available on the machine.
|
---|
Management
| Agents are managed by Jenkins master or controller
| Nodes may have dedicated management systems or scripts.
|
---|
Network Connectivity
| May require VPN or firewall rules for external agents.
| Requires network connectivity within the Jenkins network.
|
---|
Set Up Jenkins-Agent& Jenkins-Node
Step 1: In the Jenkins Dashboard, go to the "Manage Jenkins" option displayed on the left sidebar.

Step 2: Click on the Nodes under System Configuration.

Step 3: Now click on "New Node" and give a name to the Jenkins Node and select Type as "Permanent Node". Then click on "Create".

Step 4: Configure the Node settings, specify the path for remote root directory which in this case we are giving as "/home/jenkins" and use a Label for further use which here we are giving as "agent1". Leave others field as default. Now click on "Save".

Once done, we can see our Node in the Nodes section.

Step 5: Now to make it connected, Click on the Agent name and copy the code from "Run from agent command line"

and run it on terminal or command prompt from the Remote root directory of the remote machine's terminal. Now, you will be able to see Agent is connected.

Set Up Node Application
Step 1: First thing we need to do is setup the NodeJS plugin in the Jenkins. Go to manage Jenkins and then to the Plugins section. In the available plugins section search for NodeJs

Tick the box below and then install. Once done restart Jenkins.
Step 2: Go to Manage Jenkins and then to Tools and scroll down to NodeJS area.

Select "Add NodeJS" and Name it as you want and select the latest version of NodeJS available.

Now click on "Save".
Using Pipeline Script
Step 3: Once you have completed the first two steps of the previous section. You can go ahead and create a New Item.

Step 4: Name it as you want and select pipeline from the options given below and click on save.

Step 5: On the next screen, scroll down to the pipeline section and write your script for the node application.

Here, we are giving your NodeJS version and then using npm version to validate it.
pipeline{
agent any
tools{
nodejs '21.6.2'
}
stages{
stage('Example'){
steps{
sh 'npm version'
}
}
}
}
Click on Save.
Step 6: Click on the Build Now button showing on the left sidebar.

Step 7: Now go to console and you should be able to see the Node version

Scroll down to see the build successful message.

Conclusion
Jenkins agents and nodes play crucial roles within the Jenkins ecosystem. These enables an efficient and scalable automation build and deployment processes. Agents serve as worker machines and executes Jenkins build tasks while Node provides the computational resources for agents to perform tasks. As Software Development practices continue to evolve, the role of Jenkins agents and nodes remains important in context of seamless automation in Software development life cycle.
Similar Reads
Difference Between Jenkins and TeamCity
Continuous Integration and Continuous Deployment (Continuous Delivery), are commonly known as CI/CD. The primary goal of CI is to ensure that changes made by various developers interact effectively and do not introduce issues in the code. The verified and accepted changes to code are quickly made av
6 min read
Difference Between Jenkins and Bamboo
Pre-requisite: Jenkins If you are thinking of building software, you can use tools like Jenkins and Bamboo made just for it. Imagine you push new code to Git, and without any manual steps, your application gets tested and deployed to staging. Thatâs the power of CI/CD tools. Jenkins and Bamboo are t
6 min read
Differences between node.js and Tornado
Node.js and Tornado are both popular choices for building scalable and high-performance web applications and services. However, they are based on different programming languages (JavaScript and Python, respectively) and have distinct design philosophies and features. In this guide, we will explore t
6 min read
Difference Between GitLab CI and Jenkins
In the modern era, online platforms are in use at a very high rate. As the competition is very high in the market to release good and regular updates over online services or products, there is an urgent need for Continuous Integration (CI) and Continuous Development (CD) in the software development
3 min read
Difference between Maven and Ant
1. Maven :Maven is a powerful project management tool based on the Project Object Model. It helps in managing project builds, documentation, dependency, releases, etc.2. Ant :Ant is a command-line toolbox without any coding conventions or project structures, making it flexible and more manageable to
2 min read
Difference between spawn() and fork() methods in Node.js
Node.js provides several ways to create child processes, enabling you to run tasks in parallel and leverage multi-core systems efficiently. Two commonly used methods for this purpose are spawn() and fork(). While they might seem similar, they serve different purposes and have distinct features. This
4 min read
Difference Between --save and --save-dev in NodeJS
In NodeJS, when you install packages using npm (Node Package Manager), you often need to decide whether to install them as a dependency or devDependency. This is where the flags --save and --save-dev come into play. These flags control where the installed packages are placed in the package.json file
5 min read
Difference between Jira and Jira Server
Jira and Jira server are two well-known foundations in the field of project management software, each providing customers with unique benefits and features. Despite having the same core, their feature sets and deployment strategies forge different routes in supporting teams' and organizations' deman
5 min read
Difference Between process.cwd() and __dirname in Node.js
In Node.js, both process.cwd() and __dirname are used to get the directory paths, but they serve different purposes. The key difference is that process.cwd() returns the current working directory from which the Node.js process was started, while __dirname returns the directory name of the current mo
3 min read
Difference Between Lambda and Amplify in AWS
Pre-requisite: AWS By using the computing service offered by Amazon Lambda, you may run code without installing or managing servers. Almost any type of backend service or application may be executed with Lambda. Providing Lambda with your code in one of the languages it supports is all that is neces
3 min read