Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins pipeline: agent vs node?

People also ask

What is the difference between node and agent in Jenkins?

Node: A Pipeline performs most of the work in the context of one or more declared node steps. Agent: The agent directive specifies where the entire Pipeline, or a specific stage, will execute in the Jenkins environment depending on where the agent directive is placed.

What is a Jenkins Pipeline agent?

General Terms. Agent. An agent is typically a machine, or container, which connects to a Jenkins controller and executes tasks when directed by the controller. Artifact. An immutable file generated during a Build or Pipeline run which is archived onto the Jenkins Controller for later retrieval by users.

What is a node in Jenkins pipeline?

Node. A node is a machine which is part of the Jenkins environment and is capable of executing a Pipeline. Also, a node block is a key part of Scripted Pipeline syntax.

What are the 3 types of pipelines in Jenkins?

There are two types of pipelines in Jenkins: Declarative. Scripted.


The simple answer is, Agent is for declarative pipelines and node is for scripted pipelines.

In declarative pipelines the agent directive is used for specifying which agent/slave the job/task is to be executed on. This directive only allows you to specify where the task is to be executed, which agent, slave, label or docker image.

On the other hand, in scripted pipelines the node step can be used for executing a script/step on a specific agent, label, slave. The node step optionally takes the agent or label name and then a closure with code that is to be executed on that node.

declarative and scripted pipelines (edit based on the comment):

  • declarative pipelines is a new extension of the pipeline DSL (it is basically a pipeline script with only one step, a pipeline step with arguments (called directives), these directives should follow a specific syntax. The point of this new format is that it is more strict and therefore should be easier for those new to pipelines, allow for graphical editing and much more.
  • scripted pipelines is the fallback for advanced requirements.