should I use Jenkins heavyweight or flyweight executors for notifications?
Asked Answered
I

2

5

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

Infelicity answered 20/6, 2017 at 15:42 Comment(0)
S
6

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.

Stagy answered 22/6, 2017 at 21:15 Comment(0)
L
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.

Lubricious answered 21/6, 2017 at 21:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.