Jenkins "Required context class hudson.Launcher is missing" in CI
A step that needs an executor (such as sh or bat) ran without an allocated node. Those steps require a hudson.Launcher context, which only a node block (or a Declarative agent) provides, so Jenkins aborts asking you to wrap the code.
What this error means
The build fails with Required context class hudson.Launcher is missing. Perhaps you forgot to surround the code with a step that provides this, such as: node. It typically happens with agent none plus a top-level sh, or a sh in post without an agent.
Required context class hudson.Launcher is missing
Perhaps you forgot to surround the code with a step that provides this, such as: node
at org.jenkinsci.plugins.workflow.steps.DynamicContext$Typed.get(DynamicContext.java:95)Common causes
A shell step ran with no node allocated
In Scripted pipelines a sh outside node {}, or in Declarative with agent none and a stage that has no agent, leaves no executor to launch the process.
A post block runs without an agent
A post section that runs sh while the pipeline used agent none has no launcher context unless that block declares an agent.
How to fix it
Wrap the step in a node / agent
- Identify the step that needs an executor (
sh,bat,checkout). - Surround it with
node { ... }(Scripted) or give the stage anagent(Declarative). - For
post, set anagenton the stage or pipeline so the block has a launcher.
node('linux') {
sh 'make test'
}How to prevent it
- Use
agent noneonly when each stage that runs shell steps declares its own agent. - Keep executor-bound steps inside
node/agentblocks, not at pipeline top level. - Give
postblocks an agent when they invokesh/bat.