jenkins管道:代理vs节点? [英] jenkins pipeline: agent vs node?

查看:92
本文介绍了jenkins管道:代理vs节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jenkins管道中的 agent node 有什么区别?

What is the difference between an agent and a node in a jenkins pipeline?

我找到了那些定义:

  • 节点:管道执行的大多数工作是在一个或多个声明的上下文中完成的节点步骤.
  • agent :agent指令指定了整个Pipeline或特定阶段,将根据代理指令的放置位置在Jenkins环境中执行.
  • node: Most work a Pipeline performs is done 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.

因此,两者都用于执行管道步骤.但是什么时候使用哪个呢?

So both are used for executing pipeline steps. But when to use which one?

推荐答案

简单的答案是,代理用于声明性管道和节点用于脚本管道.

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

在声明性管道中, agent 指令用于指定要在其上执行作业/任务的代理/从属服务器.该指令仅允许您指定任务的执行位置,代理,从属,标签或docker映像.

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.

声明性和脚本化管道(根据评论进行编辑):

  • 声明性管道是管道DSL的新扩展(基本上是只有一步的管道脚本,带有参数的管道步骤(称为指令),这些指令应遵循特定的语法.这种新格式的要点是它更加严格,因此对于管道新手来说应该更容易,可以进行图形编辑等等.
  • 脚本化管道是高级需求的后备.
  • 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.

这篇关于jenkins管道:代理vs节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆