One of many ways to handle an HTTP request is by writing a method on your URL-bound classes. In Stapler-speak, these methods are called "web methods".
Web methods are public instance methods that has the name that starts with "do", for example:
Such a method would handle an HTTP request sent to
/.../start (again, see the reference for the exact routing rules)
Web methods can define parameters. When Stapler invokes your web method, it needs your help to figure out what you expect in those parameters, and there are several ways to do this.
Firstly, if the type of a parameter is one of the following "well-recognized" types, Stapler would instantly know what to do:
HttpServletRequest— the request object
HttpServletResponse— the response object
Secondly, you can place parameter injection annotations to instruct Jenkins what you want to see in that parameter. Unlike typical Java programming, parameter names are significant.
- @Header: requests that the value of the request HTTP header be injected.
- @QueryParameter: requests that the value of the request parameter be injected. This includes a submitted form and a query parameter.
- @AncestorInPath: Stapler will call
StaplerRequest.findAncestor(Class)and inject the obtained object. This object is the nearest "ancestor" of the specified type in the current URL.
(One can define a custom injection parameter by using the
@InjectedParameter meta annotation, which is how all these annotations are defined.)
The type of the injected parameter can be anything, and Apache Commons Beanutils is used to convert the incoming value into the appropriate Java type your method requests.