詹金斯管道:代理与节点? [英] Jenkins pipeline: agent vs node?

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

问题描述

jenkins 管道中的 agentnode 有什么区别?

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

我找到了这些定义:

  • 节点:管道在一个或多个声明的上下文中执行大部分工作节点步骤.
  • Agent:代理指令指定整个管道的位置,或具体阶段,将在 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.

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

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

推荐答案

简单的回答是,Agent 是针对 declarative 管道和 node用于脚本化管道.

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.

另一方面,在脚本化管道中,node 步骤可用于在特定代理、标签、从属设备上执行脚本/步骤.node 步骤可选地采用代理或标签名称,然后是带有要在该节点上执行的代码的闭包.

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(它基本上是一个只有一个步骤的管道脚本,一个带有参数的管道步骤(称为指令),这些指令应该遵循特定的语法.这种新格式的要点是它更严格,因此应该更容易那些新的管道,允许图形编辑等等.
  • 脚本化管道是高级要求的后备方案.

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

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