我应该使用Jenkins重量级或轻量级执行器进行通知吗? [英] should I use Jenkins heavyweight or flyweight executors for notifications?

查看:208
本文介绍了我应该使用Jenkins重量级或轻量级执行器进行通知吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Jenkins管道中,我只有几个步骤可以通知用户(在我的情况下是使用Slack集成).

I have few steps in my Jenkins pipeline that notify users, in my case using Slack integration.

将通知代码写在node块中以使用重量级执行程序还是将其留在外面以使用重量级执行程序是一种好习惯吗?

is it a good practice to write the notification code inside a node block to use a heavyweight executor or just leave it outside to make use of a flyweight executor?

根据文档 :

每个管道构建本身都使用flyweight执行程序在主数据库上运行,这是一个无计数的插槽,假定不会占用任何重要的计算能力.

Every Pipeline build itself runs on the master, using a flyweight executor — an uncounted slot that is assumed to not take any significant computational power.

该执行程序代表实际的Groovy脚本,该脚本几乎总是空闲的,等待完成一个步骤.

This executor represents the actual Groovy script, which is almost always idle, waiting for a step to complete.

轻量级执行器始终可用.

Flyweight executors are always available.

阅读此书后,我仍然不清楚是否可以使用重量级或轻量级执行程序进行通知

After reading this, it is still not clear to me if it is considered a good practice for notifications to use a heavyweight or flyweight executors

推荐答案

大多数步骤会让您知道它们需要一个(重量级)执行程序插槽(节点/代理)-请参见Daniels的答案.

Most steps will let you know that they require a (heavyweight) executor slot (node/agent) - see Daniels answer.

请记住,执行程序(重量级)是Jenkins防止Jenkins运行的计算机过载的方法.通过限制执行程序的数量,您可以限制Jenkins正在并行执行的任务的数量,因此也就限制了所需的资源.

Remember, executors (heavyweight) are Jenkins way to prevent an overload on the machine Jenkins is running on. By limiting the number of executors you're limiting the number of tasks Jenkins is executing in parallel and therefore the required resources.

对于通知,最好使用轻量级的执行程序(如果它在没有节点的情况下运行),因为它不需要您的jenkins机器的大量资源.这仍然取决于您的用例,如果使用常规或轻量级执行程序执行通知,那么到底有多重要?如果仅花费几毫秒/秒的时间发送此通知,并且您(平均)有足够的免费执行程序,则使用节点aka执行程序也不会受到损害.然后,在整个管道中使用一个节点/代理通常会更容易.

For notifications it should be fine to use a lightweight executor (if it works without a node) as it doesn't need much resources of your jenkins machine. It still depends on your use case how much it really matters if notifications are executed with a regular or a lightweight excecutor. If it only takes some milliseconds/ a second to send this notification and if you have (in average) enough free executors, it doesn't hurt to use a node aka executor. Then it is often easier to use one node / agent for your complete pipeline.

另一方面,请确保您所使用的管道不会永远阻止执行程序.例如.如果您使用输入步骤,则管道因此需要长时间等待用户输入.在这里,轻量级执行器的使用很重要.另外,对网络请求和其他可能长时间运行的任务进行超时配置也有助于防止执行程序被阻塞(常规).

On the other hand make sure that you're pipeline doesn't block an executor forever. E.g. if you use an input step and the pipeline therefore waits long time on user input. Here the usage of the lightweight executor is important. Also timeout configuration for networks request and other potentially long running task are helpful to prevent blocked (regular) executors.

希望这可以为您提供更多指导.

Hope this helps to give you some more direction.

这篇关于我应该使用Jenkins重量级或轻量级执行器进行通知吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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