0
0
JenkinsConceptBeginner · 3 min read

What is Node in Jenkins: Explanation and Usage

In Jenkins, a node is a machine or environment where Jenkins runs tasks or jobs. It can be the main Jenkins server (called the controller) or any other machine (called an agent) connected to Jenkins to perform work.
⚙️

How It Works

Think of Jenkins as a manager who assigns tasks to workers. The node is like a worker machine where these tasks get done. The main Jenkins server is one node, often called the controller, which controls the process and schedules jobs.

Other nodes, called agents, are additional machines connected to Jenkins. They help by running jobs in parallel or on different environments, like Windows or Linux. This setup lets Jenkins spread work across many machines, making automation faster and more flexible.

💻

Example

This example shows how to define a node block in a Jenkins Pipeline script to run a job on a specific node labeled 'linux-agent'.

groovy
pipeline {
  agent { label 'linux-agent' }
  stages {
    stage('Build') {
      steps {
        echo 'Building on the linux-agent node'
      }
    }
  }
}
Output
[Pipeline] echo Building on the linux-agent node [Pipeline] End of Pipeline
🎯

When to Use

Use nodes when you want to run Jenkins jobs on different machines or environments. For example, if you need to test software on Windows and Linux, you can set up nodes for each OS. Jenkins will send jobs to the right node based on labels.

Nodes are also useful to balance workload. If your main server is busy, agents can run jobs to keep things moving smoothly. This helps in large projects with many builds or tests running at the same time.

Key Points

  • A node is any machine Jenkins uses to run jobs.
  • The main Jenkins server is a node called the controller.
  • Additional nodes (agents) help run jobs in parallel or on different platforms.
  • Nodes are identified by labels to target specific environments.
  • Using nodes improves speed and flexibility of automation.

Key Takeaways

A node in Jenkins is a machine where jobs run, including the controller and agents.
Nodes allow Jenkins to run jobs on different environments or multiple machines.
Use node labels to direct jobs to the right machine for your build or test.
Adding agents as nodes helps balance workload and speeds up automation.
Pipeline scripts use node blocks to specify where to run tasks.