Package hudson.plugins.chucknorris
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 Summary
ConstructorsConstructorDescriptionRoundhouseAction(Style style, int factIndex) Constructs a RoundhouseAction with specified style and fact.RoundhouseAction(Style style, String customFact) Constructs a RoundhouseAction with a custom fact. -
Method Summary
Modifier and TypeMethodDescriptionorg.kohsuke.stapler.HttpResponsedoNewFact(org.kohsuke.stapler.StaplerRequest2 req) Picks another random fact for this build and saves it with the build, so everyone sees the same fact afterwards.The URL of this action, relative to the Jenkins root.Gets the action display name.getFact()Gets the Chuck Norris fact.Gets the fact index for locale-aware lookup in Jelly templates.This action doesn't provide any icon file.Collection<? extends Action> Returns this action as a collection of all project actions.getStyle()Gets the Chuck Norris style.Gets the URL name for this action.booleanWhether the current user may pick a new fact for this build: they need to be able to configure the job.voidonAttached(Run<?, ?> r) voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface hudson.model.Action
getDescription, getEvent, getGroup, getSemantic, isVisibleInContextMenu
-
Constructor Details
-
RoundhouseAction
Constructs a RoundhouseAction with specified style and fact.- Parameters:
style- the stylefactIndex- the fact index for locale-aware lookup
-
RoundhouseAction
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 stylecustomFact- the custom fact
-
-
Method Details
-
getDisplayName
Gets the action display name.- Specified by:
getDisplayNamein interfaceAction- Specified by:
getDisplayNamein interfaceModelObject- Returns:
- the display name
-
getIconFileName
This action doesn't provide any icon file.- Specified by:
getIconFileNamein interfaceAction- Returns:
- null
-
getUrlName
Gets the URL name for this action.- Specified by:
getUrlNamein interfaceAction- Returns:
- the URL name
-
getStyle
Gets the Chuck Norris style.- Returns:
- the style
-
getFactIndex
Gets the fact index for locale-aware lookup in Jelly templates.- Returns:
- the fact index, or null for legacy builds
-
getFact
Gets the Chuck Norris fact.- Returns:
- the fact
-
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:
getProjectActionsin interfaceSimpleBuildStep.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 byfloatingBox.jelly.- Returns:
- true if the New fact button should be shown
-
getActionUrl
The URL of this action, relative to the Jenkins root. Used byfloatingBox.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
- Specified by:
onAttachedin interfaceRunAction2
-
onLoad
- Specified by:
onLoadin interfaceRunAction2
-