Stapler Web Framework
Request Handling
Jenkins classes are bound to URLs by using Stapler.
The singleton jenkinsdoc:Jenkins[] instance is bound to the context root (most of the time "/") URL, and the rest of the objects are bound according to their reachability from this root object.
Stapler uses reflection to recursively determine how to process any given URL.
A few examples of how the URL /foo/bar could be processed:
-
A
getFoo(String)is defined on theJenkinsobject, and Stapler passesbaras a parameter. The object returned has a method calleddoIndex(…)that gets called and renders the response. -
getFoo()is defined and returns an object that has agetBarordoBarmethod. The object returned from that has an associatedindex.jellyorindex.groovyview. -
getFoo()is defined and the returned object has a view namedbar.jellyorbar.groovydefined. -
doFoo()is defined.
A number of additional ways to handle requests exist, but these are the most common.