Issue
When I write in JenkinsFile something like this:
node {
parallel (
phase1: { sh "./firstProgram" },
phase2: { sh "./secondProgram" }
)
}
does jenkins run it as different processes or just only as different threads?
Solution
The workflow-cps
plugin is what provides the parallel
functionality. Below is an excerpt from the plugin's page which discusses how parallel
works.
All program logic is run inside a “CPS VM thread”, which is just a Java thread pool that can run binary methods and figure out which continuation to do next. The parallel step uses “green threads” (also known as cooperative multitasking): it records logical thread (~ branch) names for various actions, but does not literally run them simultaneously. The program may seem to perform tasks concurrently, but only because most steps run asynchronously, while the VM thread is idle, and they may overlap in time. No Java thread is consumed except during the typically brief intervals when Groovy code is actually being run on the VM thread. The executor widget only displays an entry for the “flyweight” executor on the built-in node when the VM thread is busy; normally it is hidden.
Answered By - Sunvic