Class Run<JobT extends Job<JobT,RunT>,RunT extends Run<JobT,RunT>>
- All Implemented Interfaces:
ExtensionPoint
,DescriptorByNameOwner
,ModelObject
,PersistenceRoot
,Saveable
,SearchableModelObject
,SearchItem
,AccessControlled
,Comparable<RunT>
,WithConsoleUrl
,HistoricalBuild
,ModelObjectWithContextMenu
,OnMaster
,org.kohsuke.stapler.StaplerProxy
- Direct Known Subclasses:
AbstractBuild
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.
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
A build artifact.final class
final class
BuildBadgeAction
that shows the build is being kept.static class
class
Object that lives while the build is executed, to keep track of things that are needed only during the build.protected class
Deprecated.static final class
Used inRun.RunExecution.run(hudson.model.BuildListener)
to indicates that a fatal error in a build is reported toBuildListener
and the build should be simply aborted without further recording a stack trace.static class
Used to implementgetBuildStatusSummary()
.static class
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
Nested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem, ModelObjectWithContextMenu.MenuItemType
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Permission
protected String
Charset in which the log file is written.static final Permission
protected String
Human-readable description which is used on the main build page.protected long
Number of milli-seconds it took to run this build.static final FeedAdapter<Run>
FeedAdapter
to produce feed from the summary of this build.static final FeedAdapter<Run>
FeedAdapter
to produce feeds to show one build per project.static final int
Maximum number of artifacts to list before using switching to the tree view.protected RunT
Next build.int
Build number.static final Comparator<Run>
Sort by date.static final PermissionGroup
protected RunT
Previous build.protected final JobT
static final long
The originalQueue.Item.getId()
has not yet been mapped onto theRun
instance.protected Result
The build result.static boolean
Escape hatch for StaplerProxy-based access controlprotected long
When the build is scheduled.static final Permission
static final com.thoughtworks.xstream.XStream
static final XStream2
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected RunT
_this()
Obtains 'this' in a more type safe signature.void
Adds a new action.boolean
Checks whether keep status can be toggled.int
Ordering based on build numbers.protected BuildReference<RunT>
Called byRunMap
to obtain a reference to this run.void
delete()
Deletes this build and its entire logvoid
Deletes this build's artifacts.Serves the artifacts.void
doBuildNumber
(org.kohsuke.stapler.StaplerResponse2 rsp) Returns the build number in the body.void
doBuildStatus
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) void
doBuildTimestamp
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, String format) Returns the build time stamp in the body.org.kohsuke.stapler.HttpResponse
doConfigSubmit
(org.kohsuke.stapler.StaplerRequest2 req) void
doConsoleText
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) Sends out the raw console output.void
doConsoleText
(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) Deprecated.void
doDoDelete
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) Deletes the build when the button is pressed.void
doDoDelete
(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) Deprecated.void
doProgressiveLog
(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) Deprecated.as of 1.352 UsegetLogText().doProgressiveText(req,rsp)
void
doSubmitDescription
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) Accepts the new description.void
doToggleLogKeep
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) protected void
Called byRunMap
to drop bi-directional links in preparation for deleting a build.protected final void
execute
(Run<JobT, RunT>.RunExecution job) static Run<?,
?> Tries to find a run from an persisted identifier.final String
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.getACL()
Obtains the ACL associated with this object.getApi()
final ArtifactManager
Gets an object responsible for storing and retrieving build artifacts.Gets the artifacts (relative togetArtifactsDir()
.Deprecated.Should only be used fromStandardArtifactManager
or subclasses.getArtifactsUpTo
(int artifactsNumber) Gets the first N artifacts.Gets the subset ofActionable.getActions()
that consists ofBuildBadgeAction
s.get the fingerprints associated with this buildgetBuildsOverThreshold
(int numberOfBuilds, Result threshold) Returns the lastnumberOfBuilds
builds with a build result ≥threshold
.Gets an object which represents the single line summary of the status of this build (especially in comparison with the previous build.)<T extends Cause>
TReturns aCause
of a particular type.Returns theCause
s that triggered a build.final EnvVars
Builds up the environment variable map that's sufficient to identify a process as ours.final Charset
Gets the charset in which the log file is written.Returns a human-readable description which is used on the main build page.long
Gets the millisecond it took to build.Gets the string that says how long the build took to run.getDynamic
(String token, org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) getDynamic
(String token, org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) Deprecated.Deprecated.as of 1.305 usegetEnvironment(TaskListener)
getEnvironment
(TaskListener listener) Returns the map that contains environmental variables to be used for launching processes for this build.Deprecated.as of 1.292 UsegetEnvironment(TaskListener)
instead.long
Returns the estimated duration for this run if it is currently running.Gets theExecutor
building this job, if it's being built.Produces an identifier for this run unique in the system.boolean
Check if theRun
contains artifacts.Gets the icon color for display.getId()
Unique ID of this build.getLog()
Deprecated.since 2007-11-11.getLog
(int maxLines) Gets the log of the build as a list of strings (one per log line).Deprecated.Assumes file-based storage of the log, which is not necessarily the case for Pipelines after JEP-210.Returns an input stream that reads from the log file.Used to URL-bindAnnotatedLargeText
.int
Gets the one offExecutor
building this job, if it's being built.The project this build is for.final RunT
Obtains the next younger build in progress.getPreviousBuildsOverThreshold
(int numberOfBuilds, Result threshold) Returns the lastnumberOfBuilds
builds with a build result ≥threshold
.Returns the last build that was actually built - i.e., skipping any with Result.NOT_BUILTfinal RunT
Gets the most recent completed build excluding 'this' Run itself.Returns the last failed build before this build.Returns the last build that didn't fail before this build.Returns the last successful build before this build.long
Get theQueue.Item.getId()
of the original queue item from where thisHistoricalBuild
instance originated.Returns the build result.Get the root directory of thisRun
on the controller.final String
Returns the URL of this item relative to the parentSearchItem
.final long
When the build has started running in an executor.final Date
getTime()
Same asgetTimestamp()
but in a different type.final long
Same asgetTimestamp()
but in a different type, that is since the time of the epoch.When the build is scheduled.Gets the string that says how long since this build has started.Returns the timestamp formatted in xs:dateTime.Deprecated.UseActionable.getAllActions()
instead.getUrl()
Returns the URL of thisHistoricalBuild
, relative to the context root of Jenkins.IfisKeepLog()
returns true, returns a short, human-readable sentence that explains why it's being kept.boolean
boolean
Returns true if the build is still queued and hasn't started yet.boolean
Returns true if the build is not completed yet.boolean
Determine whether the run is being build right now.final boolean
Returns true if this build should be kept and not deleted.boolean
Returns true if the log file is still being updated.final void
keepLog()
Marks this build to be kept.void
keepLog
(boolean newValue) protected SearchIndexBuilder
Default implementation that returns empty index.protected void
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
Called when a job started building.final ArtifactManager
Selects an object responsible for storing and retrieving build artifacts.void
reload()
Reloads the build record from disk.protected final void
Deprecated.as of 1.467 Useexecute(hudson.model.Run.RunExecution)
void
save()
Save the settings to a file.void
setDescription
(String description) void
setDisplayName
(String value) void
setQueueId
(long queueId) Set the queue item ID.void
Sets thegetResult()
of this build.protected void
submit
(net.sf.json.JSONObject json) toString()
final void
updateSymlinks
(TaskListener listener) Deprecated.After JENKINS-37862 this no longer does anything.void
writeLogTo
(long offset, org.apache.commons.jelly.XMLOutput out) Used fromconsole.jelly
to write annotated log to the given output.protected Object
void
Writes the complete log from the start to finish to theOutputStream
.Methods inherited from class hudson.model.Actionable
addOrReplaceAction, doContextMenu, doContextMenu, getAction, getAction, getActions, getActions, getAllActions, removeAction, removeActions, replaceAction, replaceActions
Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName, requirePOST, sendError, sendError, sendError, 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.security.AccessControlled
checkAnyPermission, checkPermission, hasAnyPermission, hasPermission, hasPermission, hasPermission2
Methods inherited from interface hudson.model.DescriptorByNameOwner
getDescriptorByName
Methods inherited from interface jenkins.model.HistoricalBuild
getBuildStatusIconClassName, getBuildStatusUrl, getTruncatedDescription
-
Field Details
-
QUEUE_ID_UNKNOWN
public static final long QUEUE_ID_UNKNOWNThe originalQueue.Item.getId()
has not yet been mapped onto theRun
instance.- Since:
- 1.601
- See Also:
-
project
-
number
public transient int numberBuild 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.
-
previousBuild
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) protected transient volatile RunT extends Run<JobT,RunT> previousBuildPrevious build. Can be null. TODO JENKINS-22052 this is not actually implemented any more External code should usegetPreviousBuild()
-
nextBuild
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) protected transient volatile RunT extends Run<JobT,RunT> nextBuildNext build. Can be null. External code should usegetNextBuild()
-
timestamp
protected long timestampWhen the build is scheduled. -
result
The build result. This value may change while the state is inRun.State.BUILDING
. -
description
Human-readable description which is used on the main build page. It can also be quite long, and it may use markup in a format defined by aMarkupFormatter
.HistoricalBuild.getTruncatedDescription()
may be used to retrieve a size-limited description, but it implies some limitations. -
duration
protected long durationNumber of milli-seconds it took to run this build. -
charset
Charset in which the log file is written. For compatibility reason, this field may be null. For persistence, this field is string and notCharset
.- Since:
- 1.257
- See Also:
-
LIST_CUTOFF
public static final int LIST_CUTOFFMaximum number of artifacts to list before using switching to the tree view. -
XSTREAM
public static final com.thoughtworks.xstream.XStream XSTREAM -
XSTREAM2
-
ORDER_BY_DATE
Sort by date. Newer ones first. -
FEED_ADAPTER
FeedAdapter
to produce feed from the summary of this build. -
FEED_ADAPTER_LATEST
FeedAdapter
to produce feeds to show one build per project. -
PERMISSIONS
-
DELETE
-
UPDATE
-
ARTIFACTS
-
SKIP_PERMISSION_CHECK
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static boolean SKIP_PERMISSION_CHECKEscape hatch for StaplerProxy-based access control
-
-
Constructor Details
-
Run
Creates a newRun
.- Parameters:
job
- Owner job- Throws:
IOException
- See Also:
-
Run
Constructor for creating aRun
object in an arbitrary state.number
must be set manually.May be used in a
SubTask.createExecutable()
(instead of callingLazyBuildMixIn.newBuild()
). For example,MatrixConfiguration.newBuild
does this so that thetimestamp
as well asnumber
are shared with the parent build. -
Run
- See Also:
-
Run
Loads a run from a log file.- Throws:
IOException
- See Also:
-
-
Method Details
-
reload
Reloads the build record from disk.- Throws:
IOException
- Since:
- 1.410
-
onLoad
protected void onLoad()Called after the build is loaded and the object is added to the build list. -
getTransientActions
Deprecated.UseActionable.getAllActions()
instead.Return all transient actions associated with this build.- Returns:
- the list can be empty but never null. read only.
-
addAction
Adds a new action. Note: calls toActionable.getAllActions()
that happen before calls to this method may not see the update. Note: this method will always modify the actions ARunAction2
is handled specially.- Overrides:
addAction
in classActionable
-
_this
Obtains 'this' in a more type safe signature. -
compareTo
Ordering based on build numbers. If numbers are equal order based on names of parent projects. -
getQueueId
@Exported public long getQueueId()Get theQueue.Item.getId()
of the original queue item from where thisHistoricalBuild
instance originated.- Specified by:
getQueueId
in interfaceHistoricalBuild
- Returns:
- The queue item ID.
- Since:
- 1.601
-
setQueueId
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void setQueueId(long queueId) Set the queue item ID.Mapped from the
Queue.Item.getId()
.- Parameters:
queueId
- The queue item ID.
-
getResult
Description copied from interface:HistoricalBuild
Returns the build result.When a build is
in progress
, this method returns an intermediate result.- Specified by:
getResult
in interfaceHistoricalBuild
- Returns:
- The status of the build, if it has completed or some build step has set a status; may be null if the build is ongoing.
-
setResult
Sets thegetResult()
of this build. Has no effect when the result is already set and worse than the proposed result. May only be called after the build has started and before it has moved into post-production (normally meaning bothisInProgress()
andisBuilding()
are true).- Parameters:
r
- the proposed new result- Throws:
IllegalStateException
- if the build has not yet started, is in post-production, or is complete
-
getBadgeActions
Gets the subset ofActionable.getActions()
that consists ofBuildBadgeAction
s.- Specified by:
getBadgeActions
in interfaceHistoricalBuild
-
isBuilding
@Exported public boolean isBuilding()Description copied from interface:HistoricalBuild
Returns true if the build is not completed yet. This includes "not started yet" state.- Specified by:
isBuilding
in interfaceHistoricalBuild
-
isInProgress
@Exported public boolean isInProgress()Determine whether the run is being build right now.- Returns:
- true if after started and before completed.
- Since:
- 1.538
-
isLogUpdated
public boolean isLogUpdated()Returns true if the log file is still being updated. -
getExecutor
Gets theExecutor
building this job, if it's being built. Otherwise null. This method looks forExecutor
who's assigned to this build, and because of that this might not be necessarily in sync with the return value ofisBuilding()
— an executor holds on toRun
some more time even after the build is finished (for example to perform post-production processing.) -
getOneOffExecutor
Gets the one offExecutor
building this job, if it's being built. Otherwise null.- Since:
- 1.433
-
getCharset
Gets the charset in which the log file is written.- Returns:
- never null.
- Since:
- 1.257
-
getCauses
Returns theCause
s that triggered 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.
- Returns:
- can be empty but never null. read-only.
- Since:
- 1.321
-
getCause
Returns aCause
of a particular type.- Since:
- 1.362
-
isKeepLog
@Exported public final boolean isKeepLog()Returns true if this build should be kept and not deleted. (Despite the name, this refers to the entire build, not merely the log file.) This is used as a signal to theBuildDiscarder
. -
getWhyKeepLog
IfisKeepLog()
returns true, returns a short, human-readable sentence that explains why it's being kept. -
getParent
The project this build is for. -
getTimestamp
When the build is scheduled.- Specified by:
getTimestamp
in interfaceHistoricalBuild
- See Also:
-
getTime
Same asgetTimestamp()
but in a different type. -
getTimeInMillis
public final long getTimeInMillis()Same asgetTimestamp()
but in a different type, that is since the time of the epoch. -
getStartTimeInMillis
public final long getStartTimeInMillis()When the build has started running in an executor. For example, if a build is scheduled 1pm, and stayed in the queue for 1 hour (say, no idle agents), then this method returns 2pm, which is the time the job moved from the queue to the building state.- See Also:
-
getDescription
Description copied from interface:HistoricalBuild
Returns a human-readable description which is used on the main build page.It can also be quite long, and it may use markup in a format defined by a
MarkupFormatter
.HistoricalBuild.getTruncatedDescription()
may be used to retrieve a size-limited description, but it implies some limitations.- Specified by:
getDescription
in interfaceHistoricalBuild
- Returns:
- the build description.
-
getTimestampString
Gets the string that says how long since this build has started.- Returns:
- string like "3 minutes" "1 day" etc.
-
getTimestampString2
Returns the timestamp formatted in xs:dateTime. -
getDurationString
Description copied from interface:HistoricalBuild
Gets the string that says how long the build took to run.- Specified by:
getDurationString
in interfaceHistoricalBuild
-
getDuration
@Exported public long getDuration()Gets the millisecond it took to build. -
getIconColor
Description copied from interface:HistoricalBuild
Gets the icon color for display.- Specified by:
getIconColor
in interfaceHistoricalBuild
-
hasntStartedYet
public boolean hasntStartedYet()Returns true if the build is still queued and hasn't started yet. -
toString
-
getFullDisplayName
- Specified by:
getFullDisplayName
in interfaceHistoricalBuild
- Returns:
- a human-readable full display name of this build.
-
getDisplayName
- Specified by:
getDisplayName
in interfaceModelObject
-
hasCustomDisplayName
public boolean hasCustomDisplayName() -
setDisplayName
- Parameters:
value
- Set to null to revert back to the default "#NNN".- Throws:
IOException
-
getNumber
@Exported(visibility=2) public int getNumber()- Specified by:
getNumber
in interfaceHistoricalBuild
- Returns:
- A build number
-
createReference
Called byRunMap
to obtain a reference to this run.- Returns:
- Reference to the build. Never null
- Since:
- 1.556
- See Also:
-
dropLinks
protected void dropLinks()Called byRunMap
to drop bi-directional links in preparation for deleting a build.- Since:
- 1.556
- See Also:
-
getPreviousBuild
-
getPreviousCompletedBuild
Gets the most recent completed build excluding 'this' Run itself. -
getPreviousBuildInProgress
Obtains the next younger build in progress. It uses a skip-pointer so that we can compute this without O(n) computation time. This method also fixes up the skip list as we go, in a way that's concurrency safe.We basically follow the existing skip list, and wherever we find a non-optimal pointer, we remember them in 'fixUp' and update them later.
-
getPreviousBuiltBuild
Returns the last build that was actually built - i.e., skipping any with Result.NOT_BUILT -
getPreviousNotFailedBuild
Returns the last build that didn't fail before this build. -
getPreviousFailedBuild
Returns the last failed build before this build. -
getPreviousSuccessfulBuild
Returns the last successful build before this build.- Since:
- 1.383
-
getPreviousBuildsOverThreshold
@NonNull public List<RunT> getPreviousBuildsOverThreshold(int numberOfBuilds, @NonNull Result threshold) Returns the lastnumberOfBuilds
builds with a build result ≥threshold
.- Parameters:
numberOfBuilds
- the desired number of buildsthreshold
- the build result threshold- Returns:
- a list with the builds (youngest build first). May be smaller than 'numberOfBuilds' or even empty if not enough builds satisfying the threshold have been found. Never null.
- Since:
- 1.383
-
getBuildsOverThreshold
Returns the lastnumberOfBuilds
builds with a build result ≥threshold
.- Parameters:
numberOfBuilds
- the desired number of buildsthreshold
- the build result threshold- Returns:
- a list with the builds (youngest build first). May be smaller than 'numberOfBuilds' or even empty if not enough builds satisfying the threshold have been found. Never null.
- Since:
- 2.202
-
getNextBuild
- See Also:
-
getUrl
Description copied from interface:HistoricalBuild
Returns the URL of thisHistoricalBuild
, relative to the context root of Jenkins.- Specified by:
getUrl
in interfaceHistoricalBuild
- Returns:
- String like "job/foo/32/" with trailing slash but no leading slash.
-
getConsoleUrl
- Specified by:
getConsoleUrl
in interfaceWithConsoleUrl
- Returns:
- a URL relative to the context root without leading slash, such as
job/xxx/123/console
; or null if unknown or not applicable - See Also:
-
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.Obtains the absolute URL to this build. -
getSearchUrl
Description copied from interface:SearchItem
Returns the URL of this item relative to the parentSearchItem
.- Specified by:
getSearchUrl
in interfaceSearchItem
- Returns:
- URL like "foo" or "foo/bar". The path can end with '/'. The path that starts with '/' will be interpreted as the absolute path (within the context path of Jenkins.)
-
getId
Unique ID of this build. Usually the decimal form ofnumber
, but may be a formatted timestamp for historical builds. -
getRootDir
Get the root directory of thisRun
on the controller. Files related to thisRun
should be stored below this directory.- Specified by:
getRootDir
in interfacePersistenceRoot
- Returns:
- Root directory of this
Run
on the controller. Never null
-
getParameterValues
- Specified by:
getParameterValues
in interfaceHistoricalBuild
- See Also:
-
getArtifactManager
Gets an object responsible for storing and retrieving build artifacts. IfpickArtifactManager()
has previously been called on this build, and a nondefault manager selected, that will be returned. Otherwise (including if we are loading a historical build created prior to this feature)StandardArtifactManager
is used.This method should be used when existing artifacts are to be loaded, displayed, or removed. If adding artifacts, use
pickArtifactManager()
instead.- Returns:
- an appropriate artifact manager
- Since:
- 1.532
-
pickArtifactManager
Selects an object responsible for storing and retrieving build artifacts. The first time this is called on a running build,ArtifactManagerConfiguration
is checked to see if one will handle this build. If so, that manager is saved in the build and it will be used henceforth. If no manager claimed the build,StandardArtifactManager
is used.This method should be used when a build step expects to archive some artifacts. If only displaying existing artifacts, use
getArtifactManager()
instead.- Returns:
- an appropriate artifact manager
- Throws:
IOException
- if a custom manager was selected but the selection could not be saved- Since:
- 1.532
-
getArtifactsDir
Deprecated.Should only be used fromStandardArtifactManager
or subclasses.Gets the directory where the artifacts are archived. -
getArtifacts
Gets the artifacts (relative togetArtifactsDir()
.- Returns:
- The list can be empty but never null
-
getArtifactsUpTo
Gets the first N artifacts.- Returns:
- The list can be empty but never null
-
getHasArtifacts
public boolean getHasArtifacts()Check if theRun
contains artifacts. The strange method name is so that we can access it from EL.- Returns:
- true if this run has any artifacts
-
getBuildFingerprints
@NonNull @Exported(name="fingerprint", inline=true, visibility=-1) public Collection<Fingerprint> getBuildFingerprints()get the fingerprints associated with this build- Returns:
- The fingerprints
-
getLogFile
Deprecated.Assumes file-based storage of the log, which is not necessarily the case for Pipelines after JEP-210. Use other methods giving various kinds of streams such asgetLogReader()
,getLogInputStream()
, orgetLogText()
.Returns the log file.- Returns:
- The file may reference both uncompressed or compressed logs
-
getLogInputStream
Returns an input stream that reads from the log file. It will use a gzip-compressed log file (log.gz) if that exists.- Returns:
- An input stream from the log file. If the log file does not exist, the error message will be returned to the output.
- Throws:
IOException
- Since:
- 1.349
-
getLogReader
- Throws:
IOException
-
writeLogTo
public void writeLogTo(long offset, @NonNull org.apache.commons.jelly.XMLOutput out) throws IOException Used fromconsole.jelly
to write annotated log to the given output.- Throws:
IOException
- Since:
- 1.349
-
writeWholeLogTo
Writes the complete log from the start to finish to theOutputStream
. If someone is still writing to the log, this method will not return until the whole log file gets written out.The method does not close the
OutputStream
.- Throws:
IOException
InterruptedException
-
getLogText
Used to URL-bindAnnotatedLargeText
.- Returns:
- A
Run
log with annotations
-
makeSearchIndex
Description copied from class:AbstractModelObject
Default implementation that returns empty index.- Overrides:
makeSearchIndex
in classAbstractModelObject
-
getApi
-
getACL
Description copied from interface:AccessControlled
Obtains the ACL associated with this object.- Specified by:
getACL
in interfaceAccessControlled
- Returns:
- never null.
-
deleteArtifacts
Deletes this build's artifacts.- Throws:
IOException
- if we fail to delete.- Since:
- 1.350
-
delete
Deletes this build and its entire log- Throws:
IOException
- if we fail to delete.
-
run
Deprecated.as of 1.467 Useexecute(hudson.model.Run.RunExecution)
-
execute
-
updateSymlinks
@Deprecated public final void updateSymlinks(@NonNull TaskListener listener) throws InterruptedException Deprecated.After JENKINS-37862 this no longer does anything.- Throws:
InterruptedException
-
onStartBuilding
protected void onStartBuilding()Called when a job started building. -
onEndBuilding
protected void onEndBuilding()Called when a job finished building normally or abnormally. -
save
Save the settings to a file.- Specified by:
save
in interfaceSaveable
- Throws:
IOException
- if the persistence failed.
-
writeReplace
-
getLog
Deprecated.since 2007-11-11. UsegetLog(int)
instead as it avoids loading the whole log into memory unnecessarily.Gets the log of the build as a string.- Returns:
- Returns the log or an empty string if it has not been found
- Throws:
IOException
-
getLog
Gets the log of the build as a list of strings (one per log line). The number of lines returned is constrained by the maxLines parameter.- Parameters:
maxLines
- The maximum number of log lines to return. If the log is bigger than this, only the most recent lines are returned.- Returns:
- A list of log lines. Will have no more than maxLines elements.
- Throws:
IOException
- If there is a problem reading the log file.
-
doBuildStatus
public void doBuildStatus(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException - Throws:
IOException
-
getBuildStatusSummary
Gets an object which represents the single line summary of the status of this build (especially in comparison with the previous build.)- See Also:
-
doArtifact
Serves the artifacts.- Throws:
org.springframework.security.access.AccessDeniedException
- Access denied
-
doBuildNumber
Returns the build number in the body.- Throws:
IOException
-
doBuildTimestamp
public void doBuildTimestamp(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter String format) throws IOException Returns the build time stamp in the body.- Throws:
IOException
-
doConsoleText
public void doConsoleText(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException Sends out the raw console output.- Throws:
IOException
- Since:
- 2.475
-
doConsoleText
@Deprecated @StaplerNotDispatchable public void doConsoleText(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException Deprecated.- Throws:
IOException
-
doProgressiveLog
@Deprecated public void doProgressiveLog(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException Deprecated.as of 1.352 UsegetLogText().doProgressiveText(req,rsp)
Handles incremental log output.- Throws:
IOException
-
canToggleLogKeep
public boolean canToggleLogKeep()Checks whether keep status can be toggled. Normally it can, but if there is a complex reason (from subclasses) why this build must be kept, the toggle is meaningless.- Returns:
- true if
doToggleLogKeep(org.kohsuke.stapler.StaplerRequest2, org.kohsuke.stapler.StaplerResponse2)
andkeepLog(boolean)
andkeepLog()
are options - Since:
- 1.510
-
doToggleLogKeep
public void doToggleLogKeep(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException - Throws:
IOException
jakarta.servlet.ServletException
-
keepLog
Marks this build to be kept.- Throws:
IOException
-
keepLog
- Throws:
IOException
-
doDoDelete
public void doDoDelete(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException Deletes the build when the button is pressed.- Throws:
IOException
jakarta.servlet.ServletException
- Since:
- 2.475
-
doDoDelete
@Deprecated @StaplerNotDispatchable public void doDoDelete(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException Deprecated.- Throws:
IOException
javax.servlet.ServletException
-
setDescription
- Throws:
IOException
-
doSubmitDescription
public void doSubmitDescription(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException Accepts the new description.- Throws:
IOException
jakarta.servlet.ServletException
-
getEnvVars
Deprecated.as of 1.292 UsegetEnvironment(TaskListener)
instead. -
getEnvironment
Deprecated.as of 1.305 usegetEnvironment(TaskListener)
- Throws:
IOException
InterruptedException
-
getEnvironment
@NonNull public EnvVars getEnvironment(@NonNull TaskListener listener) throws IOException, InterruptedException Returns the map that contains environmental variables to be used for launching processes for this build.BuildStep
s that invoke external processes should use this. This allowsBuildWrapper
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.- Returns:
- the map with the environmental variables.
- Throws:
IOException
InterruptedException
- Since:
- 1.305
-
getCharacteristicEnvVars
Builds up the environment variable map that's sufficient to identify a process as ours. This is used to kill run-away processes viaProcessTree.killAll(Map)
. -
getExternalizableId
Produces an identifier for this run unique in the system.- Returns:
- the
AbstractItem.getFullName()
, then#
, thengetNumber()
- See Also:
-
fromExternalizableId
@CheckForNull public static Run<?,?> fromExternalizableId(String id) throws IllegalArgumentException, org.springframework.security.access.AccessDeniedException Tries to find a run from an persisted identifier.- Parameters:
id
- as produced bygetExternalizableId()
- Returns:
- the same run, or null if the job or run was not found
- Throws:
IllegalArgumentException
- if the ID is malformedorg.springframework.security.access.AccessDeniedException
- as perItemGroup.getItem(java.lang.String)
-
getEstimatedDuration
@Exported public long getEstimatedDuration()Returns the estimated duration for this run if it is currently running. Default toJob.getEstimatedDuration()
, may be overridden in subclasses if duration may depend on run specific parameters (like incremental Maven builds).- Returns:
- the estimated duration in milliseconds
- Since:
- 1.383
-
doConfigSubmit
@POST @NonNull public org.kohsuke.stapler.HttpResponse doConfigSubmit(org.kohsuke.stapler.StaplerRequest2 req) throws IOException, jakarta.servlet.ServletException, Descriptor.FormException - Throws:
IOException
jakarta.servlet.ServletException
Descriptor.FormException
-
submit
- Throws:
IOException
-
getDynamic
public Object getDynamic(String token, org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) - Overrides:
getDynamic
in classActionable
-
getDynamic
@Deprecated public Object getDynamic(String token, org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) Deprecated.- Overrides:
getDynamic
in classActionable
-
getTarget
- Specified by:
getTarget
in interfaceorg.kohsuke.stapler.StaplerProxy
-
Run<JobT extends Job<JobT,RunT>,RunT extends Run<JobT,RunT>>.RunExecution