should I use Jenkins heavyweight or flyweight executors for notifications?

China☆狼群 提交于 2019-12-10 19:16:58

问题


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

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?

According to the documentation:

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.

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


回答1:


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

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.

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.




回答2:


I tried the flyweight executor but got the following error when sending emails:

Required context class hudson.FilePath is missing

To avoid these kind of problems, I would choose the heavyweight executor.



来源:https://stackoverflow.com/questions/44657510/should-i-use-jenkins-heavyweight-or-flyweight-executors-for-notifications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!