Routing Requests

Let’s look at some real-world examples for the most common ways to process (part of) the path:

Additionally, objects can implement several interfaces to further control how Stapler processes URLs:

  • org.kohsuke.stapler.StaplerProxy allows delegating the processing of a URL to another object. So, for /foo/bar, if getFoo() returns an object x that implements StaplerProxy’s `getTarget() method, Stapler will call x.getTarget() and continue using that to process the rest of the URL (bar). This has the highest priority among all possible URL processing options. getTarget() may also return this, for example to implement permission checks: No getters or views of x will be available to anyone who doesn’t have the necessary permissions via URLs.

  • org.kohsuke.stapler.StaplerOverridable is an interface allowing designated objects to selectively override URL mappings. If the designated override objects do not have a handler for the request, the host object (that implements StaplerOverridable) will handle the request.

  • org.kohsuke.stapler.StaplerFallback allows delegating the processing of a URL to another object, similar to StaplerProxy, but has the lowest priority among all possible URL processing options.

For more information on how Stapler binds (or staples) a Java Object Model to a URL hierarchy, see the Stapler Reference Documentation.

Since Jenkins 2.138.4 and 2.154, Jenkins places restrictions not inherent to Stapler on which methods and fields are eligible for routing. Learn more

Debugging hints

The following static fields can be set to true (e.g. via Script Console) while Jenkins is running to enable various debugging aids:


Stapler responses will include X-Stapler-Trace-… headers that explain how the corresponding request was routed. Additionally, the 404 error page will also include this information, as well as alternative routes for the last path component (which resulted in the 404 error). The corresponding Java system property is stapler.trace. This is enabled by default if Jenkins is run using mvn -pl war jetty:run (core) or mvn hpi:run (plugins).


As above, but only for requests that have the X-Stapler-Trace header. The corresponding Java system property is stapler.trace.per-request.