a few notes about jenkins pipeline

A few days ago I wrote a jenkins pipeline and tried to run it. However, it always showed pending. After struggling for a while, I found the root cause: the master node was disabled. This prevented the pipeline from running. I posted some snippet from the jenkins pipeline plugin tutorial page in this post. It briefly describes the difference between heavy-weight executor and fly-weight executor.

https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md

Why are there two executors consumed by one Pipeline build?

  • Every Pipeline itself runs on the master, using a flyweight executor.
  • This executor represents the actual Groovy script, which is almost always idle, waiting for a step to complete.
  • Flyweight executors are always available.

When you run a node step:

  • A regular heavyweight executor is allocated on a node (usually an agent) matching the label expression, as soon as one is available. This executor represents the real work being done on the node.
  • If you start a second build of the Pipeline while the first is still paused with the one available executor, you will see both Pipeline builds running on master. But only the first will have grabbed the one available executor on the agent; the other part of jobname #11 will be shown in Build Queue (1). (shortly after, the console log for the second build will note that it is still waiting for an available executor).

I give a few words about the snippet:

1. There are two kinds of executors in jenkins: fly-weight executor and heavy-weight executor.

2. The fly-weight executor is on the master node and is always available.

3. The fly-weight executor isn’t taken into account when jenkins evaluates the available executors.

4. When a pipeline starts to run, it will always start to run in the master node using the fly-weight executor.

5. When the pipeline runs a node step, a heavy-weight executor is allocated on a agent.

6. The heavy-weight executor performs the real build task.

7. The heavy-weight executor is taken into account when jenkins evaluates the available executors.