public abstract class Job<JobT extends Job<JobT,RunT>,RunT extends Run<JobT,RunT>> extends AbstractItem implements ExtensionPoint, org.kohsuke.stapler.StaplerOverridable, ModelObjectWithChildren, OnMaster
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
Job.LastItemListener |
ExtensionPoint.LegacyInstancesAreScopedToHudsonModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem| Modifier and Type | Field and Description |
|---|---|
static HistoryWidget.Adapter<Run> |
HISTORY_ADAPTER |
protected int |
nextBuildNumber
Next build number.
|
protected CopyOnWriteList<JobProperty<? super JobT>> |
properties
List of properties configured for this project.
|
RunIdMigrator |
runIdMigrator |
description, displayName, name, PRONOUN| Modifier | Constructor and Description |
|---|---|
protected |
Job(ItemGroup parent,
String name) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
ModelObjectWithContextMenu.ContextMenu |
doChildrenContextMenu(org.kohsuke.stapler.StaplerRequest request,
org.kohsuke.stapler.StaplerResponse response)
Generates the context menu to list up all the children.
|
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)
Looks up a build by its ID.
|
RunT |
getBuildByNumber(int n) |
File |
getBuildDir()
Directory for storing
Run records. |
BuildDiscarder |
getBuildDiscarder()
Returns the configured build discarder for this job, via
BuildDiscarderProperty, 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 |
getBuildStatusIconClassName() |
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() |
protected List<RunT> |
getEstimatedDurationCandidates()
Returns candidate build for calculating the estimated duration of the current run.
|
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.
|
<T extends JobProperty> |
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.
|
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 |
movedTo(DirectlyModifiableTopLevelItemGroup destination,
AbstractItem newItem,
File destDir)
Notify this item it's been moved to another location, replaced by newItem (might be the same object, but not guaranteed).
|
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 |
onCreatedFromScratch()
When an item is created from scratch (instead of copied),
this method will be invoked.
|
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.
|
<T extends JobProperty> |
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.
|
checkPermission, delete, doConfigDotXml, doDoDelete, doReload, doSetName, doSubmitDescription, getAbsoluteUrl, getApi, getConfigFile, getDescription, getDescriptorByName, getDisplayName, getDisplayNameOrNull, getFullDisplayName, getFullName, getName, getParent, getRelativeDisplayNameFrom, getRelativeNameFrom, getRelativeNameFrom, getRelativeNameFromGroup, getRootDir, getSearchName, getSearchUrl, getShortUrl, getUrl, hasPermission, resolveForCLI, setDescription, setDisplayName, setDisplayNameOrNull, toString, updateByXml, updateByXml, writeConfigDotXmladdAction, doContextMenu, getAction, getAction, getActions, getActions, getAllActions, replaceActiongetSearch, getSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendErrorclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetDisplayNamegetSearchgetSearchIndexprotected 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
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public transient RunIdMigrator runIdMigrator
public static final HistoryWidget.Adapter<Run> HISTORY_ADAPTER
public void save()
throws IOException
AbstractItemsave in interface Itemsave in interface Saveablesave in class AbstractItemIOException - if the persistence failed.public void onCreatedFromScratch()
ItemonCreatedFromScratch in interface ItemonCreatedFromScratch in class AbstractItempublic void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException
AbstractItemItem is loaded from disk.
This is an opportunity 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
AbstractItemperformDelete in class AbstractItemIOExceptionInterruptedExceptionpublic 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()
AbstractProject but historically it was defined here.)public int assignBuildNumber()
throws IOException
IOException@Exported public int getNextBuildNumber()
public EnvVars getCharacteristicEnvVars()
ProcessTree.killAll(Map).@Nonnull public EnvVars getEnvironment(@CheckForNull Node node, @Nonnull 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.)IOExceptionInterruptedExceptionpublic 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()
BuildDiscarderProperty, or null if none.public void setBuildDiscarder(BuildDiscarder bd) throws IOException
IOException@Deprecated public LogRotator getLogRotator()
getBuildDiscarder().LogRotator is configured as BuildDiscarder.@Deprecated public void setLogRotator(LogRotator logRotator) throws IOException
setBuildDiscarder(BuildDiscarder)IOExceptionpublic void logRotate()
throws IOException,
InterruptedException
IOExceptionInterruptedExceptionpublic boolean supportsLogRotator()
protected SearchIndexBuilder makeSearchIndex()
AbstractModelObjectmakeSearchIndex in class AbstractModelObjectpublic Collection<? extends Job> getAllJobs()
AbstractItemItem contains as descendants.getAllJobs in interface ItemgetAllJobs in class AbstractItempublic void addProperty(JobProperty<? super JobT> jobProp) throws IOException
JobProperty.IOExceptionpublic void removeProperty(JobProperty<? super JobT> jobProp) throws IOException
JobPropertyIOExceptionpublic <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()protected HistoryWidget createHistoryWidget()
LazyBuildMixIn.createHistoryWidget()public void renameTo(String newName) throws IOException
renameTo in class AbstractItemIOExceptionpublic void movedTo(DirectlyModifiableTopLevelItemGroup destination, AbstractItem newItem, File destDir) throws IOException
AbstractItemDerived classes can override this method to add some specific behavior on move, but have to call parent method so the item is actually setup within it's new parent.
movedTo in class AbstractItemIOExceptionItems.move(AbstractItem, jenkins.model.DirectlyModifiableTopLevelItemGroup)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 AbstractItemIOExceptionInterruptedException@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 RunT getBuildByNumber(int n)
n - The build number.Run.getNumber(),
LazyBuildMixIn.getBuildByNumber(int)@WithBridgeMethods(value=java.util.List.class) @Deprecated 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)
LazyBuildMixIn.getNearestBuild(int)public RunT getNearestOldBuild(int n)
LazyBuildMixIn.getNearestOldBuild(int)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()
LazyBuildMixIn._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.LazyBuildMixIn.removeRun(RunT)@Exported public RunT getLastBuild()
LazyBuildMixIn.getLastBuild()@Exported public RunT getFirstBuild()
LazyBuildMixIn.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)
protected List<RunT> getEstimatedDurationCandidates()
public long getEstimatedDuration()
public PermalinkList getPermalinks()
PermalinkProjectAction.Permalinks defined for this job.public ModelObjectWithContextMenu.ContextMenu doChildrenContextMenu(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) throws Exception
ModelObjectWithChildrendoChildrenContextMenu in interface ModelObjectWithChildrenException@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
IOExceptionjavax.servlet.ServletExceptionDescriptor.FormExceptionprotected void submit(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
throws IOException,
javax.servlet.ServletException,
Descriptor.FormException
IOExceptionjavax.servlet.ServletExceptionDescriptor.FormExceptionpublic void doDescription(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
throws IOException
IOExceptionpublic void doBuildStatus(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
throws IOException
IOExceptionpublic String getBuildStatusUrl()
public String getBuildStatusIconClassName()
public Graph getBuildTimeGraph()
public void doDoRename(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
throws IOException,
javax.servlet.ServletException
IOExceptionjavax.servlet.ServletExceptionpublic void doRssAll(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
throws IOException,
javax.servlet.ServletException
IOExceptionjavax.servlet.ServletExceptionpublic void doRssFailed(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
throws IOException,
javax.servlet.ServletException
IOExceptionjavax.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()
Copyright © 2019. All rights reserved.