hudson.model
Class JobProperty<J extends Job<?,?>>

java.lang.Object
  extended by hudson.model.JobProperty<J>
Type Parameters:
J - When you restrict your job property to be only applicable to a certain subtype of Job, you can use this type parameter to improve the type signature of this class. See JobPropertyDescriptor.isApplicable(Class).
All Implemented Interfaces:
ExtensionPoint, Describable<JobProperty<?>>, BuildStep
Direct Known Subclasses:
AuthorizationMatrixProperty, ParametersDefinitionProperty

@ExportedBean
public abstract class JobProperty<J extends Job<?,?>>
extends Object
implements Describable<JobProperty<?>>, BuildStep, ExtensionPoint

Extensible property of Job.

Plugins can extend this to define custom properties for Jobs. JobPropertys show up in the user configuration screen, and they are persisted with the job object.

Configuration screen should be defined in config.jelly. Within this page, the JobProperty instance is available as instance variable (while it refers to Job.

Starting 1.150, JobProperty implements BuildStep, meaning it gets the same hook as Publisher and Builder. The primary intention of this mechanism is so that JobPropertys can add actions to the new build. The perform(AbstractBuild, Launcher, BuildListener) and prebuild(AbstractBuild, BuildListener) are invoked after those of Publishers.

Since:
1.72
Author:
Kohsuke Kawaguchi
See Also:
JobPropertyDescriptor

Nested Class Summary
 
Nested classes/interfaces inherited from interface hudson.tasks.BuildStep
BuildStep.PublisherList
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
 
Fields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
 
Constructor Summary
JobProperty()
           
 
Method Summary
 JobPropertyDescriptor getDescriptor()
          Gets the descriptor for this instance.
 Action getJobAction(J job)
          Deprecated. as of 1.341. Override getJobActions(Job) instead.
 Collection<? extends Action> getJobActions(J job)
          Actions to be displayed in the job page.
 Collection<?> getJobOverrides()
           
 Action getProjectAction(AbstractProject<?,?> project)
           
 Collection<? extends Action> getProjectActions(AbstractProject<?,?> project)
          Returns action objects if this BuildStep has actions to contribute to a Project.
 BuildStepMonitor getRequiredMonitorService()
          Returns BuildStepMonitor.NONE by default, as JobPropertys normally don't depend on its previous result.
 Collection<? extends SubTask> getSubTasks()
          Contributes SubTasks to AbstractProject.getSubTasks()
 boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener)
          Runs the step over the given build and reports the progress to the listener.
 boolean prebuild(AbstractBuild<?,?> build, BuildListener listener)
          Runs before the build begins.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobProperty

public JobProperty()
Method Detail

getDescriptor

public JobPropertyDescriptor getDescriptor()
Gets the descriptor for this instance.

Descriptor is a singleton for every concrete Describable implementation, so if a.getClass()==b.getClass() then a.getDescriptor()==b.getDescriptor() must hold.

Specified by:
getDescriptor in interface Describable<JobProperty<?>>

getJobAction

public Action getJobAction(J job)
Deprecated. as of 1.341. Override getJobActions(Job) instead.


getJobActions

public Collection<? extends Action> getJobActions(J job)
Actions to be displayed in the job page.

Returning actions from this method allows a job property to add them to the left navigation bar in the job page.

Action can implement additional marker interface to integrate with the UI in different ways.

Parameters:
job - Always the same as owner but passed in anyway for backward compatibility (I guess.) You really need not use this value at all.
Returns:
can be empty but never null.
Since:
1.341
See Also:
ProminentProjectAction, PermalinkProjectAction

prebuild

public boolean prebuild(AbstractBuild<?,?> build,
                        BuildListener listener)
Description copied from interface: BuildStep
Runs before the build begins.

Specified by:
prebuild in interface BuildStep
Returns:
true if the build can continue, false if there was an error and the build needs to be aborted.

perform

public boolean perform(AbstractBuild<?,?> build,
                       Launcher launcher,
                       BuildListener listener)
                throws InterruptedException,
                       IOException
Runs the step over the given build and reports the progress to the listener.

A plugin can contribute the action object to Build#getActions() so that a 'report' becomes a part of the persisted data of Build. This is how JUnit plugin attaches the test report to a build page, for example.

Invoked after Publishers have run.

Specified by:
perform in interface BuildStep
Returns:
true if the build can continue, false if there was an error and the build needs to be aborted.
Throws:
InterruptedException - If the build is interrupted by the user (in an attempt to abort the build.) Normally the BuildStep implementations may simply forward the exception it got from its lower-level functions.
IOException - If the implementation wants to abort the processing when an IOException happens, it can simply propagate the exception to the caller. This will cause the build to fail, with the default error message. Implementations are encouraged to catch IOException on its own to provide a better error message, if it can do so, so that users have better understanding on why it failed.

getRequiredMonitorService

public BuildStepMonitor getRequiredMonitorService()
Returns BuildStepMonitor.NONE by default, as JobPropertys normally don't depend on its previous result.

Specified by:
getRequiredMonitorService in interface BuildStep

getProjectAction

public final Action getProjectAction(AbstractProject<?,?> project)
Specified by:
getProjectAction in interface BuildStep

getProjectActions

public final Collection<? extends Action> getProjectActions(AbstractProject<?,?> project)
Description copied from interface: BuildStep
Returns action objects if this BuildStep has actions to contribute to a Project.

Project calls this method for every BuildStep that it owns when the rendering is requested.

This action can have optional jobMain.jelly view, which will be aggregated into the main panel of the job top page. The jelly file should have an <h2> tag that shows the section title, followed by some block elements to render the details of the section.

Specified by:
getProjectActions in interface BuildStep
Parameters:
project - Project that owns this build step, since BuildStep object doesn't usually have this "parent" pointer.
Returns:
can be empty but never null.

getJobOverrides

public Collection<?> getJobOverrides()

getSubTasks

public Collection<? extends SubTask> getSubTasks()
Contributes SubTasks to AbstractProject.getSubTasks()

Since:
1.377


Copyright © 2004-2013 Hudson. All Rights Reserved.