|
||||||||||
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.Run<JobT,RunT>
@ExportedBean public abstract class Run<JobT extends Job<JobT,RunT>,RunT extends Run<JobT,RunT>>
A particular execution of Job
.
Custom Run
type is always used in conjunction with
a custom Job
type, so there's no separate registration
mechanism for custom Run
types.
RunListener
Nested Class Summary | |
---|---|
class |
Run.Artifact
A build artifact. |
class |
Run.ArtifactList
|
class |
Run.KeepLogBuildBadge
BuildBadgeAction that shows the logs are being kept. |
static class |
Run.RedirectUp
|
class |
Run.RunExecution
Object that lives while the build is executed, to keep track of things that are needed only during the build. |
protected class |
Run.Runner
Deprecated. as of 1.467 Please use Run.RunExecution |
static class |
Run.RunnerAbortedException
Used in Run.RunExecution.run(hudson.model.BuildListener) to indicates that a fatal error in a build
is reported to BuildListener and the build should be simply aborted
without further recording a stack trace. |
static class |
Run.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 | |
---|---|
static Permission |
ARTIFACTS
See Functions.isArtifactsPermissionEnabled() |
protected String |
charset
Charset in which the log file is written. |
static Permission |
DELETE
|
protected String |
description
Human-readable description. |
protected long |
duration
Number of milli-seconds it took to run this build. |
static FeedAdapter<Run> |
FEED_ADAPTER
FeedAdapter to produce feed from the summary of this build. |
static FeedAdapter<Run> |
FEED_ADAPTER_LATEST
FeedAdapter to produce feeds to show one build per project. |
protected static ThreadLocal<SimpleDateFormat> |
ID_FORMATTER
|
static int |
LIST_CUTOFF
Maximum number of artifacts to list before using switching to the tree view. |
protected RunT |
nextBuild
Next build. |
int |
number
Build number. |
static Comparator<Run> |
ORDER_BY_DATE
Sort by date. |
static PermissionGroup |
PERMISSIONS
|
protected RunT |
previousBuild
Previous build. |
protected JobT |
project
|
protected Result |
result
The build result. |
protected hudson.model.Run.State |
state
The current build state. |
protected long |
timestamp
When the build is scheduled. |
static int |
TREE_CUTOFF
Maximum number of artifacts to show in tree view before just showing a link. |
static Permission |
UPDATE
|
static com.thoughtworks.xstream.XStream |
XSTREAM
|
static XStream2 |
XSTREAM2
Alias to XSTREAM so that one can access additional methods on XStream2 more easily. |
Fields inherited from interface hudson.model.Saveable |
---|
NOOP |
Constructor Summary | |
---|---|
protected |
Run(JobT job)
Creates a new Run . |
protected |
Run(JobT job,
Calendar timestamp)
Constructor for creating a Run object in
an arbitrary state. |
protected |
Run(JobT project,
File buildDir)
Loads a run from a log file. |
protected |
Run(JobT job,
long timestamp)
|
Method Summary | ||
---|---|---|
protected RunT |
_this()
Obtains 'this' in a more type safe signature. |
|
void |
addAction(Action a)
Adds a new action. |
|
boolean |
canToggleLogKeep()
Checks whether keep status can be toggled. |
|
void |
checkPermission(Permission p)
Convenient short-cut for getACL().checkPermission(permission) |
|
int |
compareTo(RunT that)
Ordering based on build numbers. |
|
void |
delete()
Deletes this build and its entire log |
|
void |
deleteArtifacts()
Deletes this build's artifacts. |
|
DirectoryBrowserSupport |
doArtifact()
Serves the artifacts. |
|
void |
doBuildNumber(org.kohsuke.stapler.StaplerResponse rsp)
Returns the build number in the body. |
|
void |
doBuildStatus(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
|
|
void |
doBuildTimestamp(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp,
String format)
Returns the build time stamp in the body. |
|
org.kohsuke.stapler.HttpResponse |
doConfigSubmit(org.kohsuke.stapler.StaplerRequest req)
|
|
void |
doConsoleText(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Sends out the raw console output. |
|
void |
doDoDelete(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Deletes the build when the button is pressed. |
|
void |
doProgressiveLog(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Deprecated. as of 1.352 Use getLogText().doProgressiveText(req,rsp) |
|
void |
doSubmitDescription(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Accepts the new description. |
|
void |
doToggleLogKeep(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
|
|
protected void |
execute(Run.RunExecution job)
|
|
static Run<?,?> |
fromExternalizableId(String id)
|
|
String |
getAbsoluteUrl()
Deprecated. This method shall NEVER be used during HTML page rendering, as it's too easy for misconfiguration to break this value, with network set up like Apache reverse proxy. This method is only intended for the remote API clients who cannot resolve relative references. |
|
ACL |
getACL()
Obtains the ACL associated with this object. |
|
Api |
getApi()
|
|
List<Run.Artifact> |
getArtifacts()
Gets the artifacts (relative to getArtifactsDir() . |
|
File |
getArtifactsDir()
Gets the directory where the artifacts are archived. |
|
List<Run.Artifact> |
getArtifactsUpTo(int n)
Gets the first N artifacts. |
|
List<BuildBadgeAction> |
getBadgeActions()
Gets the subset of Actionable.getActions() that consists of BuildBadgeAction s. |
|
Run.Summary |
getBuildStatusSummary()
Gets an object which represents the single line summary of the status of this build (especially in comparison with the previous build.) |
|
String |
getBuildStatusUrl()
|
|
|
getCause(Class<T> type)
Returns a Cause of a particular type. |
|
List<Cause> |
getCauses()
Returns the Cause s that tirggered a build. |
|
EnvVars |
getCharacteristicEnvVars()
Builds up the environment variable map that's sufficient to identify a process as ours. |
|
Charset |
getCharset()
Gets the charset in which the log file is written. |
|
String |
getDescription()
|
|
Descriptor |
getDescriptorByName(String className)
Exposes all Descriptor s by its name to URL. |
|
String |
getDisplayName()
|
|
long |
getDuration()
Gets the millisecond it took to build. |
|
String |
getDurationString()
Gets the string that says how long the build took to run. |
|
Object |
getDynamic(String token,
org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
|
|
EnvVars |
getEnvironment()
Deprecated. as of 1.305 use getEnvironment(TaskListener) |
|
EnvVars |
getEnvironment(TaskListener listener)
Returns the map that contains environmental variables to be used for launching processes for this build. |
|
Map<String,String> |
getEnvVars()
Deprecated. as of 1.292 Use getEnvironment() instead. |
|
long |
getEstimatedDuration()
Returns the estimated duration for this run if it is currently running. |
|
Executor |
getExecutor()
Gets the Executor building this job, if it's being built. |
|
String |
getExternalizableId()
|
|
String |
getFullDisplayName()
|
|
boolean |
getHasArtifacts()
Returns true if this run has any artifacts. |
|
BallColor |
getIconColor()
Gets the icon color for display. |
|
String |
getId()
Unique ID of this build. |
|
static DateFormat |
getIDFormatter()
Get the date formatter used to convert the directory name in to a timestamp This is nasty exposure of private data, but needed all the time the directory containing the build is used as it's timestamp. |
|
String |
getLog()
Deprecated. since 2007-11-11. Use getLog(int) instead as it avoids loading
the whole log into memory unnecessarily. |
|
List<String> |
getLog(int maxLines)
Gets the log of the build as a list of strings (one per log line). |
|
File |
getLogFile()
Returns the log file. |
|
InputStream |
getLogInputStream()
Returns an input stream that reads from the log file. |
|
Reader |
getLogReader()
|
|
AnnotatedLargeText |
getLogText()
Used to URL-bind AnnotatedLargeText . |
|
RunT |
getNextBuild()
|
|
int |
getNumber()
|
|
Executor |
getOneOffExecutor()
Gets the one off Executor building this job, if it's being built. |
|
JobT |
getParent()
The project this build is for. |
|
RunT |
getPreviousBuild()
|
|
RunT |
getPreviousBuildInProgress()
Obtains the next younger build in progress. |
|
List<RunT> |
getPreviousBuildsOverThreshold(int numberOfBuilds,
Result threshold)
Returns the last 'numberOfBuilds' builds with a build result >= 'threshold'. |
|
RunT |
getPreviousBuiltBuild()
Returns the last build that was actually built - i.e., skipping any with Result.NOT_BUILT |
|
RunT |
getPreviousCompletedBuild()
Gets the most recent completed build excluding 'this' Run itself. |
|
RunT |
getPreviousFailedBuild()
Returns the last failed build before this build. |
|
RunT |
getPreviousNotFailedBuild()
Returns the last build that didn't fail before this build. |
|
RunT |
getPreviousSuccessfulBuild()
Returns the last successful build before this build. |
|
Result |
getResult()
Returns the build result. |
|
File |
getRootDir()
Root directory of this Run on the master. |
|
String |
getSearchUrl()
Returns the URL of this item relative to the parent SearchItem . |
|
long |
getStartTimeInMillis()
When the build has started running in an executor. |
|
Date |
getTime()
Same as getTimestamp() but in a different type. |
|
long |
getTimeInMillis()
Same as getTimestamp() but in a different type, that is since the time of the epoc. |
|
Calendar |
getTimestamp()
When the build is scheduled. |
|
String |
getTimestampString()
Gets the string that says how long since this build has started. |
|
String |
getTimestampString2()
Returns the timestamp formatted in xs:dateTime. |
|
List<Action> |
getTransientActions()
Return all transient actions associated with this build. |
|
String |
getTruncatedDescription()
Returns the length-limited description. |
|
String |
getUrl()
Returns the URL of this Run , relative to the context root of Hudson. |
|
String |
getWhyKeepLog()
If isKeepLog() returns true, returns a short, human-readable
sentence that explains why it's being kept. |
|
boolean |
hasCustomDisplayName()
|
|
boolean |
hasntStartedYet()
Returns true if the build is still queued and hasn't started yet. |
|
boolean |
hasPermission(Permission p)
Convenient short-cut for getACL().hasPermission(permission) |
|
boolean |
isBuilding()
Returns true if the build is not completed yet. |
|
boolean |
isKeepLog()
Returns true if this log file should be kept and not deleted. |
|
boolean |
isLogUpdated()
Returns true if the log file is still being updated. |
|
void |
keepLog()
Marks this build to keep the log. |
|
void |
keepLog(boolean newValue)
|
|
protected SearchIndexBuilder |
makeSearchIndex()
Default implementation that returns empty index. |
|
protected void |
onEndBuilding()
Called when a job finished building normally or abnormally. |
|
protected void |
onLoad()
Called after the build is loaded and the object is added to the build list. |
|
protected void |
onStartBuilding()
Called when a job started building. |
|
void |
reload()
Reloads the build record from disk. |
|
protected void |
run(Run.Runner job)
Deprecated. as of 1.467 Use execute(RunExecution) |
|
void |
save()
Save the settings to a file. |
|
void |
setDescription(String description)
|
|
void |
setDisplayName(String value)
|
|
void |
setResult(Result r)
|
|
protected void |
submit(net.sf.json.JSONObject json)
|
|
String |
toString()
|
|
void |
writeLogTo(long offset,
org.apache.commons.jelly.XMLOutput out)
Used from console.jelly to write annotated log to the given output. |
|
void |
writeWholeLogTo(OutputStream out)
Writes the complete log from the start to finish to the OutputStream . |
Methods inherited from class hudson.model.Actionable |
---|
doContextMenu, getAction, getAction, getActions, getActions |
Methods inherited from class hudson.model.AbstractModelObject |
---|
getSearch, getSearchIndex, getSearchName, requirePOST, sendError, sendError, sendError, sendError, sendError |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final transient JobT extends Job<JobT,RunT> project
public int number
In earlier versions < 1.24, this number is not unique nor continuous, but going forward, it will, and this really replaces the build id.
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) protected transient volatile RunT extends Run<JobT,RunT> previousBuild
RunMap
.
External code should use getPreviousBuild()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) protected transient volatile RunT extends Run<JobT,RunT> nextBuild
getNextBuild()
protected final transient long timestamp
protected volatile Result result
State#BUILDING
.
protected volatile String description
protected transient volatile hudson.model.Run.State state
protected long duration
protected String charset
Charset
.
getCharset()
protected static final ThreadLocal<SimpleDateFormat> ID_FORMATTER
public static final int LIST_CUTOFF
public static final int TREE_CUTOFF
public static final com.thoughtworks.xstream.XStream XSTREAM
public static final XStream2 XSTREAM2
XSTREAM
so that one can access additional methods on XStream2
more easily.
public static final Comparator<Run> ORDER_BY_DATE
public static final FeedAdapter<Run> FEED_ADAPTER
FeedAdapter
to produce feed from the summary of this build.
public static final FeedAdapter<Run> FEED_ADAPTER_LATEST
FeedAdapter
to produce feeds to show one build per project.
public static final PermissionGroup PERMISSIONS
public static final Permission DELETE
public static final Permission UPDATE
public static final Permission ARTIFACTS
Functions.isArtifactsPermissionEnabled()
Constructor Detail |
---|
protected Run(JobT job) throws IOException
Run
.
IOException
protected Run(JobT job, Calendar timestamp)
Run
object in
an arbitrary state.
protected Run(JobT job, long timestamp)
protected Run(JobT project, File buildDir) throws IOException
IOException
Method Detail |
---|
public void reload() throws IOException
IOException
protected void onLoad()
public List<Action> getTransientActions()
public void addAction(Action a)
Actionable
addAction
in class Actionable
protected RunT _this()
public int compareTo(RunT that)
compareTo
in interface Comparable<RunT extends Run<JobT,RunT>>
@Exported public Result getResult()
When a build is in progress
, this method
returns an intermediate result.
public void setResult(Result r)
public List<BuildBadgeAction> getBadgeActions()
Actionable.getActions()
that consists of BuildBadgeAction
s.
@Exported public boolean isBuilding()
public boolean isLogUpdated()
@Exported @CheckForNull public Executor getExecutor()
Executor
building this job, if it's being built.
Otherwise null.
This method looks for Executor
who's assigned to this build,
and because of that this might not be necessarily in sync with the return value of isBuilding()
—
an executor holds on to some more time even after the build is finished (for example to
perform post-production processing.)
public Executor getOneOffExecutor()
Executor
building this job, if it's being built.
Otherwise null.
public final Charset getCharset()
public List<Cause> getCauses()
Cause
s that tirggered a build.
If a build sits in the queue for a long time, multiple build requests made during this period are all rolled up into one build, hence this method may return a list.
public <T extends Cause> T getCause(Class<T> type)
Cause
of a particular type.
@Exported public final boolean isKeepLog()
BuildDiscarder
.
public String getWhyKeepLog()
isKeepLog()
returns true, returns a short, human-readable
sentence that explains why it's being kept.
public JobT getParent()
@Exported public Calendar getTimestamp()
getStartTimeInMillis()
public final Date getTime()
getTimestamp()
but in a different type.
public final long getTimeInMillis()
getTimestamp()
but in a different type, that is since the time of the epoc.
public final long getStartTimeInMillis()
getTimestamp()
@Exported public String getDescription()
public String getTruncatedDescription()
public String getTimestampString()
public String getTimestampString2()
public String getDurationString()
@Exported public long getDuration()
public BallColor getIconColor()
public boolean hasntStartedYet()
public String toString()
toString
in class Object
@Exported public String getFullDisplayName()
public String getDisplayName()
getDisplayName
in interface ModelObject
public boolean hasCustomDisplayName()
public void setDisplayName(String value) throws IOException
value
- Set to null to revert back to the default "#NNN".
IOException
@Exported(visibility=2) public int getNumber()
public RunT getPreviousBuild()
public final RunT getPreviousCompletedBuild()
public final RunT getPreviousBuildInProgress()
We basically follow the existing skip list, and wherever we find a non-optimal pointer, we remember them in 'fixUp' and update them later.
public RunT getPreviousBuiltBuild()
public RunT getPreviousNotFailedBuild()
public RunT getPreviousFailedBuild()
public RunT getPreviousSuccessfulBuild()
public List<RunT> getPreviousBuildsOverThreshold(int numberOfBuilds, Result threshold)
numberOfBuilds
- the desired number of buildsthreshold
- the build result threshold
public RunT getNextBuild()
public String getUrl()
Run
, relative to the context root of Hudson.
@Exported(visibility=2, name="url") public final String getAbsoluteUrl()
public final String getSearchUrl()
SearchItem
SearchItem
.
getSearchUrl
in interface SearchItem
@Exported public String getId()
public static DateFormat getIDFormatter()
public Descriptor getDescriptorByName(String className)
DescriptorByNameOwner
Descriptor
s by its name to URL.
Implementation should always delegate to Jenkins.getDescriptorByName(String)
.
getDescriptorByName
in interface DescriptorByNameOwner
className
- Either Descriptor.getId()
(recommended) or the short name.public File getRootDir()
Run
on the master.
Files related to this Run
should be stored below this directory.
getRootDir
in interface PersistenceRoot
public File getArtifactsDir()
@Exported public List<Run.Artifact> getArtifacts()
getArtifactsDir()
.
public List<Run.Artifact> getArtifactsUpTo(int n)
public boolean getHasArtifacts()
The strange method name is so that we can access it from EL.
public File getLogFile()
public InputStream getLogInputStream() throws IOException
IOException
public Reader getLogReader() throws IOException
IOException
public void writeLogTo(long offset, org.apache.commons.jelly.XMLOutput out) throws IOException
IOException
public void writeWholeLogTo(OutputStream out) throws IOException, InterruptedException
OutputStream
.
If someone is still writing to the log, this method will not return until the whole log
file gets written out.
IOException
InterruptedException
public AnnotatedLargeText getLogText()
AnnotatedLargeText
.
protected SearchIndexBuilder makeSearchIndex()
AbstractModelObject
makeSearchIndex
in class AbstractModelObject
public Api getApi()
public void checkPermission(Permission p)
AccessControlled
getACL().checkPermission(permission)
checkPermission
in interface AccessControlled
public boolean hasPermission(Permission p)
AccessControlled
getACL().hasPermission(permission)
hasPermission
in interface AccessControlled
public ACL getACL()
AccessControlled
getACL
in interface AccessControlled
public void deleteArtifacts() throws IOException
IOException
- if we fail to delete.public void delete() throws IOException
IOException
- if we fail to delete.protected final void run(Run.Runner job)
execute(RunExecution)
protected final void execute(Run.RunExecution job)
protected void onStartBuilding()
protected void onEndBuilding()
public void save() throws IOException
save
in interface Saveable
IOException
- if the persistence failed.@Deprecated public String getLog() throws IOException
getLog(int)
instead as it avoids loading
the whole log into memory unnecessarily.
IOException
public List<String> getLog(int maxLines) throws IOException
maxLines
- The maximum number of log lines to return. If the log
is bigger than this, only the most recent lines are returned.
IOException
- If there is a problem reading the log file.public void doBuildStatus(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException
IOException
public String getBuildStatusUrl()
public Run.Summary getBuildStatusSummary()
public DirectoryBrowserSupport doArtifact()
public void doBuildNumber(org.kohsuke.stapler.StaplerResponse rsp) throws IOException
IOException
public void doBuildTimestamp(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, @QueryParameter String format) throws IOException
IOException
public void doConsoleText(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException
IOException
public void doProgressiveLog(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException
getLogText().doProgressiveText(req,rsp)
IOException
public boolean canToggleLogKeep()
doToggleLogKeep(org.kohsuke.stapler.StaplerRequest, org.kohsuke.stapler.StaplerResponse)
and keepLog(boolean)
and keepLog()
are optionspublic void doToggleLogKeep(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
@CLIMethod(name="keep-build") public final void keepLog() throws IOException
IOException
public void keepLog(boolean newValue) throws IOException
IOException
public void doDoDelete(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public void setDescription(String description) throws IOException
IOException
public void doSubmitDescription(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public Map<String,String> getEnvVars()
getEnvironment()
instead.
public EnvVars getEnvironment() throws IOException, InterruptedException
getEnvironment(TaskListener)
IOException
InterruptedException
public EnvVars getEnvironment(TaskListener listener) throws IOException, InterruptedException
BuildStep
s that invoke external processes should use this.
This allows BuildWrapper
s and other project configurations (such as JDK selection)
to take effect.
Unlike earlier getEnvVars()
, this map contains the whole environment,
not just the overrides, so one can introspect values to change its behavior.
null
.
IOException
InterruptedException
public final EnvVars getCharacteristicEnvVars()
ProcessTree.killAll(Map)
.
public String getExternalizableId()
public static Run<?,?> fromExternalizableId(String id)
@Exported public long getEstimatedDuration()
Job.getEstimatedDuration()
, may be overridden in subclasses
if duration may depend on run specific parameters (like incremental Maven builds).
public org.kohsuke.stapler.HttpResponse doConfigSubmit(org.kohsuke.stapler.StaplerRequest req) throws IOException, javax.servlet.ServletException, Descriptor.FormException
IOException
javax.servlet.ServletException
Descriptor.FormException
protected void submit(net.sf.json.JSONObject json) throws IOException
IOException
public Object getDynamic(String token, org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
getDynamic
in class Actionable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |