Class RoundhouseAction

java.lang.Object
hudson.plugins.chucknorris.RoundhouseAction
All Implemented Interfaces:
Action, ModelObject, RunAction2, SimpleBuildStep.LastBuildAction

@ExportedBean public final class RoundhouseAction extends Object implements RunAction2, SimpleBuildStep.LastBuildAction
RoundhouseAction keeps the style and fact associated with the action. For more info, please watch https://www.youtube.com/watch?v=Vb7lnpk3tRY

The style, fact and fact index are exported to the remote API, so a build's api/json carries them for dashboards, chat bots and build monitors.

Author:
cliffano
  • Constructor Details

    • RoundhouseAction

      public RoundhouseAction(Style style, int factIndex)
      Constructs a RoundhouseAction with specified style and fact.
      Parameters:
      style - the style
      factIndex - the fact index for locale-aware lookup
    • RoundhouseAction

      public RoundhouseAction(Style style, String customFact)
      Constructs a RoundhouseAction with a custom fact. The fact's text is stored with the build, so the build keeps it when the custom facts change, and it is shown as written in every language.
      Parameters:
      style - the style
      customFact - the custom fact
  • Method Details

    • getDisplayName

      public String getDisplayName()
      Gets the action display name.
      Specified by:
      getDisplayName in interface Action
      Specified by:
      getDisplayName in interface ModelObject
      Returns:
      the display name
    • getIconFileName

      public String getIconFileName()
      This action doesn't provide any icon file.
      Specified by:
      getIconFileName in interface Action
      Returns:
      null
    • getUrlName

      public String getUrlName()
      Gets the URL name for this action.
      Specified by:
      getUrlName in interface Action
      Returns:
      the URL name
    • getStyle

      @Exported(visibility=2) public Style getStyle()
      Gets the Chuck Norris style.
      Returns:
      the style
    • getFactIndex

      @Exported(visibility=2) public Integer getFactIndex()
      Gets the fact index for locale-aware lookup in Jelly templates.
      Returns:
      the fact index, or null for legacy builds
    • getFact

      @Exported(visibility=2) public String getFact()
      Gets the Chuck Norris fact.
      Returns:
      the fact
    • getProjectActions

      public Collection<? extends Action> getProjectActions()
      Returns this action as a collection of all project actions. Default jenkins behavior is to get the action on the last successful build (Stable or Unstable) while we want the last completed build (Stable, Unstable or Failure).
      Specified by:
      getProjectActions in interface SimpleBuildStep.LastBuildAction
      Returns:
      the project actions
    • isNewFactAllowed

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isNewFactAllowed()
      Whether the current user may pick a new fact for this build: they need to be able to configure the job. Used by floatingBox.jelly.
      Returns:
      true if the New fact button should be shown
    • getActionUrl

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public String getActionUrl()
      The URL of this action, relative to the Jenkins root. Used by floatingBox.jelly, where the action is shown on the job page.
      Returns:
      the URL of this action
    • doNewFact

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doNewFact(org.kohsuke.stapler.StaplerRequest2 req) throws IOException
      Picks another random fact for this build and saves it with the build, so everyone sees the same fact afterwards. The style still follows the build result. Needs a POST (with the CSRF crumb) and permission to configure the job.
      Parameters:
      req - the request
      Returns:
      a redirect to the job page
      Throws:
      IOException - if the build cannot be saved
    • onAttached

      public void onAttached(Run<?,?> r)
      Specified by:
      onAttached in interface RunAction2
    • onLoad

      public void onLoad(Run<?,?> r)
      Specified by:
      onLoad in interface RunAction2