Stapler Web Framework

This site is the new docs site currently being tested. For the actual docs in use please go to https://www.jenkins.io/doc.

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 the Jenkins object, and Stapler passes bar as a parameter. The object returned has a method called doIndex(…) that gets called and renders the response.

  • getFoo() is defined and returns an object that has a getBar or doBar method. The object returned from that has an associated index.jelly or index.groovy view.

  • getFoo() is defined and the returned object has a view named bar.jelly or bar.groovy defined.

  • doFoo() is defined.

A number of additional ways to handle requests exist, but these are the most common.

Views

Jenkins' model objects have multiple views that are used to render HTML pages about each object. Views are written in Jelly or Groovy and can be composed of a number of different partial views (or view fragments).