Wraps a block in a contextual object as in BodyInvoker.withContext
; cf. getContext
.
Takes a single context
argument plus a block. Example:
withContext(new MyConsoleLogFilter()) {
sh 'process'
}
Automatically merges its argument with contextual objects in the case of ConsoleLogFilter
, LauncherDecorator
, and EnvironmentExpander
.
For use from trusted code, such as global libraries, which can manipulate internal Jenkins APIs.
Do not attempt to pass objects defined in Groovy;
only Java-defined objects are supported.
Really you should avoid using this and getContext
and just define a Step
in a plugin instead.