Class BuildViewExtension

  • All Implemented Interfaces:
    ExtensionPoint

    public abstract class BuildViewExtension
    extends Object
    implements ExtensionPoint
    This class servers as an extension point to render additional configuration entries for a build action.

    It is useful to add additional properties to the build; regardless of whether or not this happens on a build or re-build.

    The extension needs to implement a "value.groovy" or "value.jelly" which gets added into the form tag of the build submission. The name of this file can be overridden via getValuePage().

    The fields will be put into the JSON form data inside the StaplerRequest when the build is executed. For simplicity's sake, the method onBuild(AbstractProject, StaplerRequest) will be called whenever a build is configured.

    Author:
    mhschroe
    • Constructor Detail

      • BuildViewExtension

        public BuildViewExtension()
    • Method Detail

      • getValuePage

        public String getValuePage()
      • onBuild

        public List<Action> onBuild​(AbstractProject<?,​?> project,
                                    org.kohsuke.stapler.StaplerRequest req)
                             throws javax.servlet.ServletException
        This function is being called, shortly before a build is being scheduled.

        It allows you to inspect and alter the project and StaplerRequest and return additional Actions to be contributed to the build.

        If a ParametersAction is returned, its definitions will be merged with the ParametersAction created from the build parameter page.

        Parameters:
        project - the project for which a build will be started
        req - the WebUI request that triggered the build.
        Returns:
        a list of actions to contribute. May be empty, but never null.
        Throws:
        javax.servlet.ServletException - in case the build should be prevented entirely.
      • callAll

        public static final List<Action> callAll​(AbstractProject<?,​?> project,
                                                 org.kohsuke.stapler.StaplerRequest req)
                                          throws javax.servlet.ServletException
        Throws:
        javax.servlet.ServletException
      • mergeParameters

        public static final void mergeParameters​(List<Action> actions)
      • getSubmittedFormSafely

        public static final net.sf.json.JSONObject getSubmittedFormSafely​(org.kohsuke.stapler.StaplerRequest req)
        Calling getSubmittedForm, if no form is present in a StaplerRequest will throw an ugly exception. Call this to avoid the exception.

        This can happen when triggering jobs that do not have parameters, and thus trigger a build purely via an HTTP GET without a form.

        Parameters:
        req - the user-request
        Returns:
        the JSON form, or null if none is present (or the request was not a POST)