|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecthudson.model.AbstractModelObject
hudson.model.Actionable
hudson.model.AbstractItem
hudson.model.Job<JobT,RunT>
public abstract class Job<JobT extends Job<JobT,RunT>,RunT extends Run<JobT,RunT>>
A job is an runnable entity under the monitoring of Hudson.
Every time it "runs", it will be recorded as a Run object.
To create a custom job type, extend TopLevelItemDescriptor and put Extension on it.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface hudson.ExtensionPoint |
|---|
ExtensionPoint.LegacyInstancesAreScopedToHudson |
| Nested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu |
|---|
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.MenuItem |
| Field Summary | |
|---|---|
protected static HistoryWidget.Adapter<Run> |
HISTORY_ADAPTER
|
protected int |
nextBuildNumber
Next build number. |
protected CopyOnWriteList<JobProperty<? super JobT>> |
properties
List of UserPropertys configured for this project. |
| Fields inherited from class hudson.model.AbstractItem |
|---|
description, displayName, name, PRONOUN |
| Fields inherited from interface hudson.model.Item |
|---|
BUILD, CANCEL, CONFIGURE, CREATE, DELETE, DISCOVER, EXTENDED_READ, PERMISSIONS, READ, WIPEOUT, WORKSPACE |
| Fields inherited from interface hudson.model.Saveable |
|---|
NOOP |
| Constructor Summary | |
|---|---|
protected |
Job(ItemGroup parent,
String name)
|
| Method Summary | ||
|---|---|---|
protected abstract SortedMap<Integer,? extends RunT> |
_getRuns()
Gets all the runs. |
|
void |
addProperty(JobProperty<? super JobT> jobProp)
Adds JobProperty. |
|
int |
assignBuildNumber()
Allocates a new buildCommand number. |
|
protected HistoryWidget |
createHistoryWidget()
|
|
void |
delete()
Deletes this item. |
|
void |
doBuildStatus(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Returns the image that shows the current buildCommand status. |
|
void |
doConfigSubmit(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Accepts submission from the configuration page. |
|
void |
doDescription(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Accepts and serves the job description |
|
void |
doDoRename(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Renames this job. |
|
void |
doRssAll(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
|
|
void |
doRssFailed(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
|
|
ACL |
getACL()
Returns the ACL for this object. |
|
Collection<? extends Job> |
getAllJobs()
Gets all the jobs that this Item contains as descendants. |
|
List<JobProperty<? super JobT>> |
getAllProperties()
List of all JobProperty exposed primarily for the remoting API. |
|
RunT |
getBuild(String id)
Deprecated. since 2008-06-15. This is only used to support backward compatibility with old URLs. |
|
RunT |
getBuildByNumber(int n)
|
|
File |
getBuildDir()
Directory for storing Run records. |
|
BuildDiscarder |
getBuildDiscarder()
Returns the configured build discarder for this job, or null if none. |
|
RunT |
getBuildForCLI(String id)
|
|
HealthReport |
getBuildHealth()
Get the current health report for a job. |
|
List<HealthReport> |
getBuildHealthReports()
|
|
RunList<RunT> |
getBuilds()
Gets the read-only view of all the builds. |
|
List<RunT> |
getBuilds(Fingerprint.RangeSet rs)
Obtains all the Runs whose build numbers matches the given Fingerprint.RangeSet. |
|
SortedMap<Integer,RunT> |
getBuildsAsMap()
Gets all the builds in a map. |
|
RunList<RunT> |
getBuildsByTimestamp(long start,
long end)
Deprecated. as of 1.372. Should just do getBuilds().byTimestamp(s,e) to avoid code bloat in Job. |
|
String |
getBuildStatusUrl()
|
|
Graph |
getBuildTimeGraph()
|
|
EnvVars |
getCharacteristicEnvVars()
Builds up the environment variable map that's sufficient to identify a process as ours. |
|
Object |
getDynamic(String token,
org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
|
|
EnvVars |
getEnvironment(Node node,
TaskListener listener)
Creates an environment variable override for launching processes for this project. |
|
long |
getEstimatedDuration()
|
|
RunT |
getFirstBuild()
Returns the oldest build in the record. |
|
BallColor |
getIconColor()
Used as the color of the status ball for the project. |
|
RunT |
getLastBuild()
Returns the last build. |
|
List<RunT> |
getLastBuildsOverThreshold(int numberOfBuilds,
Result threshold)
Returns the last 'numberOfBuilds' builds with a build result >= 'threshold' |
|
RunT |
getLastCompletedBuild()
Returns the last completed build, if any. |
|
RunT |
getLastFailedBuild()
Returns the last failed build, if any. |
|
RunT |
getLastStableBuild()
Returns the last stable build, if any. |
|
RunT |
getLastSuccessfulBuild()
Returns the last successful build, if any. |
|
RunT |
getLastUnstableBuild()
Returns the last unstable build, if any. |
|
RunT |
getLastUnsuccessfulBuild()
Returns the last build that was anything but stable, if any. |
|
LogRotator |
getLogRotator()
Deprecated. as of 1.503 Use getBuildDiscarder(). |
|
RunT |
getNearestBuild(int n)
Gets the youngest build #m that satisfies n<=m. |
|
RunT |
getNearestOldBuild(int n)
Gets the latest build #m that satisfies m<=n. |
|
RunList<RunT> |
getNewBuilds()
Gets the read-only view of the recent builds. |
|
int |
getNextBuildNumber()
Peeks the next build number. |
|
Collection<?> |
getOverrides()
Overrides from job properties. |
|
PermalinkList |
getPermalinks()
Gets all the PermalinkProjectAction.Permalinks defined for this job. |
|
String |
getPronoun()
Get the term used in the UI to represent this kind of Item. |
|
Map<JobPropertyDescriptor,JobProperty<? super JobT>> |
getProperties()
Gets all the job properties configured for this job. |
|
|
getProperty(Class<T> clazz)
Gets the specific property, or null if the propert is not configured for this job. |
|
JobProperty |
getProperty(String className)
Bind JobPropertys to URL spaces. |
|
Queue.Item |
getQueueItem()
If this job is in the build queue, return its item. |
|
BuildTimelineWidget |
getTimeline()
|
|
List<Widget> |
getWidgets()
|
|
abstract boolean |
isBuildable()
Returns true if we should display "build now" icon |
|
boolean |
isBuilding()
Returns true if a build of this project is in progress. |
|
protected boolean |
isHoldOffBuildUntilSave()
|
|
boolean |
isInQueue()
|
|
boolean |
isKeepDependencies()
If true, it will keep all the build logs of dependency components. |
|
boolean |
isLogUpdated()
Returns true if the log file is still being updated. |
|
boolean |
isNameEditable()
Returns whether the name of this job can be changed by user. |
|
void |
logRotate()
Perform log rotation. |
|
protected SearchIndexBuilder |
makeSearchIndex()
Default implementation that returns empty index. |
|
void |
onCopiedFrom(Item src)
When a Item is copied from existing one,
the files are first copied on the file system,
then it will be loaded, then this method will be invoked
to perform any implementation-specific work. |
|
void |
onLoad(ItemGroup<? extends Item> parent,
String name)
Called right after when a Item is loaded from disk. |
|
protected void |
performDelete()
Does the real job of deleting the item. |
|
|
removeProperty(Class<T> clazz)
Removes the property of the given type. |
|
void |
removeProperty(JobProperty<? super JobT> jobProp)
Removes JobProperty |
|
protected abstract void |
removeRun(RunT run)
Called from Run to remove it from this job. |
|
void |
renameTo(String newName)
Renames a job. |
|
void |
save()
Save the settings to a file. |
|
protected void |
saveNextBuildNumber()
|
|
void |
setBuildDiscarder(BuildDiscarder bd)
|
|
void |
setLogRotator(LogRotator logRotator)
Deprecated. as of 1.503 Use setBuildDiscarder(BuildDiscarder) |
|
protected void |
submit(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Derived class can override this to perform additional config submission work. |
|
boolean |
supportsLogRotator()
True if this instance supports log rotation configuration. |
|
void |
updateNextBuildNumber(int next)
Programatically updates the next build number. |
|
| Methods inherited from class hudson.model.Actionable |
|---|
addAction, doContextMenu, getAction, getAction, getActions, getActions |
| Methods inherited from class hudson.model.AbstractModelObject |
|---|
getSearch, getSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface hudson.search.SearchableModelObject |
|---|
getSearch |
| Methods inherited from interface hudson.search.SearchItem |
|---|
getSearchIndex |
| Field Detail |
|---|
protected transient volatile int nextBuildNumber
In 1.28 and earlier, this field was stored in the project configuration file, so even though this is marked as transient, don't move it around.
protected CopyOnWriteList<JobProperty<? super JobT extends Job<JobT,RunT>>> properties
UserPropertys configured for this project.
protected static final HistoryWidget.Adapter<Run> HISTORY_ADAPTER
| Constructor Detail |
|---|
protected Job(ItemGroup parent,
String name)
| Method Detail |
|---|
public void save()
throws IOException
AbstractItem
save in interface Itemsave in interface Saveablesave in class AbstractItemIOException - if the persistence failed.
public void onLoad(ItemGroup<? extends Item> parent,
String name)
throws IOException
AbstractItemItem is loaded from disk.
This is an opporunity to do a post load processing.
onLoad in interface ItemonLoad in class AbstractItemname - Name of the directory (not a path --- just the name portion) from
which the configuration was loaded. This usually becomes the
name of this item.
IOExceptionpublic void onCopiedFrom(Item src)
AbstractItemItem is copied from existing one,
the files are first copied on the file system,
then it will be loaded, then this method will be invoked
to perform any implementation-specific work.
onCopiedFrom in interface ItemonCopiedFrom in class AbstractItemsrc - Item from which it's copied from. The same type as this. Never null.
protected void performDelete()
throws IOException,
InterruptedException
AbstractItem
performDelete in class AbstractItemIOException
InterruptedExceptionprotected boolean isHoldOffBuildUntilSave()
protected void saveNextBuildNumber()
throws IOException
IOException@Exported public boolean isInQueue()
@Exported public Queue.Item getQueueItem()
public boolean isBuilding()
public boolean isLogUpdated()
public String getPronoun()
AbstractItemItem. Must start with a capital letter.
getPronoun in class AbstractItempublic boolean isNameEditable()
@Exported public boolean isKeepDependencies()
public int assignBuildNumber()
throws IOException
IOException@Exported public int getNextBuildNumber()
public EnvVars getCharacteristicEnvVars()
ProcessTree.killAll(Map).
public EnvVars getEnvironment(Node node,
TaskListener listener)
throws IOException,
InterruptedException
This is for process launching outside the build execution (such as polling, tagging, deployment, etc.) that happens in a context of a specific job.
node - Node to eventually run a process on. The implementation must cope with this parameter being null
(in which case none of the node specific properties would be reflected in the resulting override.)
IOException
InterruptedException
public void updateNextBuildNumber(int next)
throws IOException
Much of Hudson assumes that the build number is unique and monotonic, so
this method can only accept a new value that's bigger than
getLastBuild() returns. Otherwise it'll be no-op.
IOExceptionpublic BuildDiscarder getBuildDiscarder()
public void setBuildDiscarder(BuildDiscarder bd)
throws IOException
IOExceptionpublic LogRotator getLogRotator()
getBuildDiscarder().
LogRotator is configured as BuildDiscarder.
public void setLogRotator(LogRotator logRotator)
throws IOException
setBuildDiscarder(BuildDiscarder)
IOException
public void logRotate()
throws IOException,
InterruptedException
IOException
InterruptedExceptionpublic boolean supportsLogRotator()
protected SearchIndexBuilder makeSearchIndex()
AbstractModelObject
makeSearchIndex in class AbstractModelObjectpublic Collection<? extends Job> getAllJobs()
AbstractItemItem contains as descendants.
getAllJobs in interface ItemgetAllJobs in class AbstractItem
public void addProperty(JobProperty<? super JobT> jobProp)
throws IOException
JobProperty.
IOException
public void removeProperty(JobProperty<? super JobT> jobProp)
throws IOException
JobProperty
IOException
public <T extends JobProperty> T removeProperty(Class<T> clazz)
throws IOException
IOExceptionpublic Map<JobPropertyDescriptor,JobProperty<? super JobT>> getProperties()
@Exported(name="property",
inline=true)
public List<JobProperty<? super JobT>> getAllProperties()
JobProperty exposed primarily for the remoting API.
public <T extends JobProperty> T getProperty(Class<T> clazz)
public JobProperty getProperty(String className)
JobPropertys to URL spaces.
public Collection<?> getOverrides()
getOverrides in interface org.kohsuke.stapler.StaplerOverridableJobProperty.getJobOverrides()public List<Widget> getWidgets()
protected HistoryWidget createHistoryWidget()
public void renameTo(String newName)
throws IOException
renameTo in class AbstractItemIOException
public void delete()
throws IOException,
InterruptedException
AbstractItem
Any exception indicates the deletion has failed, but AbortException would prevent the caller
from showing the stack trace. This
delete in interface Itemdelete in class AbstractItemIOException
InterruptedException@Exported public abstract boolean isBuildable()
@Exported(name="allBuilds",
visibility=-2)
@WithBridgeMethods(value=java.util.List.class)
public RunList<RunT> getBuilds()
@Exported(name="builds") public RunList<RunT> getNewBuilds()
public List<RunT> getBuilds(Fingerprint.RangeSet rs)
Runs whose build numbers matches the given Fingerprint.RangeSet.
public SortedMap<Integer,RunT> getBuildsAsMap()
@Deprecated public RunT getBuild(String id)
public RunT getBuildByNumber(int n)
n - The build number.
Run.getNumber()
@WithBridgeMethods(value=java.util.List.class)
public RunList<RunT> getBuildsByTimestamp(long start,
long end)
getBuilds().byTimestamp(s,e) to avoid code bloat in Job.
@CLIResolver
public RunT getBuildForCLI(String id)
throws org.kohsuke.args4j.CmdLineException
org.kohsuke.args4j.CmdLineExceptionpublic RunT getNearestBuild(int n)
public RunT getNearestOldBuild(int n)
public Object getDynamic(String token,
org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
getDynamic in class Actionablepublic File getBuildDir()
Run records.
Some Jobs may not have backing data store for Runs, but
those Jobs that use file system for storing data should use this
directory for consistency.
RunMapprotected abstract SortedMap<Integer,? extends RunT> _getRuns()
protected abstract void removeRun(RunT run)
Run to remove it from this job.
The files are deleted already. So all the callee needs to do is to remove
a reference from this Job.
@Exported public RunT getLastBuild()
@Exported public RunT getFirstBuild()
@Exported public RunT getLastSuccessfulBuild()
Result.SUCCESS or Result.UNSTABLE.
getLastStableBuild()@Exported public RunT getLastUnsuccessfulBuild()
getLastSuccessfulBuild()@Exported public RunT getLastUnstableBuild()
getLastSuccessfulBuild()@Exported public RunT getLastStableBuild()
getLastSuccessfulBuild()@Exported public RunT getLastFailedBuild()
@Exported public RunT getLastCompletedBuild()
public List<RunT> getLastBuildsOverThreshold(int numberOfBuilds,
Result threshold)
public long getEstimatedDuration()
public PermalinkList getPermalinks()
PermalinkProjectAction.Permalinks defined for this job.
@Exported(visibility=2,
name="color")
public BallColor getIconColor()
public HealthReport getBuildHealth()
@Exported(name="healthReport") public List<HealthReport> getBuildHealthReports()
public void doConfigSubmit(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
throws IOException,
javax.servlet.ServletException,
Descriptor.FormException
IOException
javax.servlet.ServletException
Descriptor.FormException
protected void submit(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
throws IOException,
javax.servlet.ServletException,
Descriptor.FormException
IOException
javax.servlet.ServletException
Descriptor.FormException
public void doDescription(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
throws IOException
IOException
public void doBuildStatus(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
throws IOException
IOExceptionpublic String getBuildStatusUrl()
public Graph getBuildTimeGraph()
public void doDoRename(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
throws IOException,
javax.servlet.ServletException
IOException
javax.servlet.ServletException
public void doRssAll(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
throws IOException,
javax.servlet.ServletException
IOException
javax.servlet.ServletException
public void doRssFailed(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
throws IOException,
javax.servlet.ServletException
IOException
javax.servlet.ServletExceptionpublic ACL getACL()
ACL for this object.
We need to override the identical method in AbstractItem because we won't
call getACL(Job) otherwise (single dispatch)
getACL in interface AccessControlledgetACL in class AbstractItempublic BuildTimelineWidget getTimeline()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||