public abstract class Job<JobT extends Job<JobT,RunT>,RunT extends Run<JobT,RunT>> extends AbstractItem implements ExtensionPoint, org.kohsuke.stapler.StaplerOverridable, ModelObjectWithChildren
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 |
static class |
Job.SubItemBuildsLocationImpl |
ExtensionPoint.LegacyInstancesAreScopedToHudson
ModelObjectWithContextMenu.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, TASK_NOUN
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 void |
checkRename(String newName)
Allows subclasses to block renames for domain-specific reasons.
|
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)
Deprecated.
Exists for backwards compatibility, use
AbstractItem.doConfirmRename(java.lang.String) instead. |
void |
doRssAll(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp) |
void |
doRssChangelog(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
RSS feed for changes in this project.
|
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
Run s 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.Permalink s 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 property is not configured for
this job.
|
JobProperty |
getProperty(String className)
Bind
JobProperty s 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. |
<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.
|
delete, doCheckNewName, doConfigDotXml, doConfirmRename, doDoDelete, doReload, doSetName, doSubmitDescription, getAbsoluteUrl, getApi, getConfigFile, getDescription, getDisplayName, getDisplayNameOrNull, getFullDisplayName, getFullName, getName, getParent, getRelativeDisplayNameFrom, getRelativeNameFromGroup, getRootDir, getSearchName, getSearchUrl, getShortUrl, getTaskNoun, getUrl, performDelete, resolveForCLI, setDescription, setDisplayName, setDisplayNameOrNull, toString, updateByXml, updateByXml, writeConfigDotXml
addAction, addOrReplaceAction, doContextMenu, getAction, getAction, getActions, getActions, getAllActions, removeAction, removeActions, replaceAction, replaceActions
getSearch, getSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getDisplayName
getRelativeNameFrom, getRelativeNameFrom
getSearch
getSearchIndex
checkPermission, hasPermission, hasPermission
getDescriptorByName
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
@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
AbstractItem
save
in interface Item
save
in interface Saveable
save
in class AbstractItem
IOException
- if the persistence failed.public void onCreatedFromScratch()
Item
onCreatedFromScratch
in interface Item
public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException
AbstractItem
Item
is loaded from disk.
This is an opportunity to do a post load processing.onLoad
in interface Item
onLoad
in class AbstractItem
name
- 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.IOException
public void onCopiedFrom(Item src)
AbstractItem
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.
onCopiedFrom
in interface Item
onCopiedFrom
in class AbstractItem
src
- Item from which it's copied from. The same type as this
. Never null.public 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()
AbstractItem
Item
. Must start with a capital letter.getPronoun
in class AbstractItem
public boolean isNameEditable()
isNameEditable
in class AbstractItem
AbstractItem.name
can be modified by a userAbstractItem.checkRename(java.lang.String)
,
AbstractItem.renameTo(java.lang.String)
@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.)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.
IOException
public 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)
IOException
public void logRotate() throws IOException, InterruptedException
IOException
InterruptedException
public boolean supportsLogRotator()
protected SearchIndexBuilder makeSearchIndex()
AbstractModelObject
makeSearchIndex
in class AbstractModelObject
public Collection<? extends Job> getAllJobs()
AbstractItem
Item
contains as descendants.getAllJobs
in interface Item
getAllJobs
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
IOException
public 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)
JobProperty
s to URL spaces.public Collection<?> getOverrides()
getOverrides
in interface org.kohsuke.stapler.StaplerOverridable
JobProperty.getJobOverrides()
protected HistoryWidget createHistoryWidget()
LazyBuildMixIn.createHistoryWidget()
public void renameTo(String newName) throws IOException
renameTo
in class AbstractItem
IOException
public void movedTo(DirectlyModifiableTopLevelItemGroup destination, AbstractItem newItem, File destDir) throws IOException
AbstractItem
Derived 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 AbstractItem
IOException
Items.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 Item
delete
in class AbstractItem
IOException
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)
Run
s 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.CmdLineException
public 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 Actionable
public File getBuildDir()
Run
records.
Some Job
s may not have backing data store for Run
s, but
those Job
s that use file system for storing data should use this
directory for consistency.
RunMap
protected 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)
numberOfBuilds
builds with a build result ≥ threshold
protected List<RunT> getEstimatedDurationCandidates()
public long getEstimatedDuration()
public PermalinkList getPermalinks()
PermalinkProjectAction.Permalink
s defined for this job.public void doRssChangelog(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public ModelObjectWithContextMenu.ContextMenu doChildrenContextMenu(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) throws Exception
ModelObjectWithChildren
doChildrenContextMenu
in interface ModelObjectWithChildren
Exception
@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
IOException
public String getBuildStatusUrl()
public String getBuildStatusIconClassName()
public Graph getBuildTimeGraph()
@Deprecated public void doDoRename(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
AbstractItem.doConfirmRename(java.lang.String)
instead.IOException
javax.servlet.ServletException
protected void checkRename(String newName) throws Failure
checkRename
in class AbstractItem
newName
- the new name for the itemFailure
- if the rename should be blockedcheckRename(java.lang.String)
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.ServletException
public 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 AccessControlled
getACL
in class AbstractItem
public BuildTimelineWidget getTimeline()
Copyright © 2004–2018. All rights reserved.