Class Run<JobT extends Job<JobT,RunT>,RunT extends Run<JobT,RunT>>
- java.lang.Object
-
- hudson.model.AbstractModelObject
-
- hudson.model.Actionable
-
- hudson.model.Run<JobT,RunT>
-
- All Implemented Interfaces:
ExtensionPoint,DescriptorByNameOwner,ModelObject,PersistenceRoot,Saveable,SearchableModelObject,SearchItem,AccessControlled,Comparable<RunT>,ModelObjectWithContextMenu,OnMaster,org.kohsuke.stapler.StaplerProxy
- Direct Known Subclasses:
AbstractBuild
@ExportedBean public abstract class Run<JobT extends Job<JobT,RunT>,RunT extends Run<JobT,RunT>> extends Actionable implements ExtensionPoint, Comparable<RunT>, AccessControlled, PersistenceRoot, DescriptorByNameOwner, OnMaster, org.kohsuke.stapler.StaplerProxy
A particular execution ofJob.Custom
Runtype is always used in conjunction with a customJobtype, so there's no separate registration mechanism for customRuntypes.- Author:
- Kohsuke Kawaguchi
- See Also:
RunListener
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classRun.ArtifactA build artifact.classRun.ArtifactListclassRun.KeepLogBuildBadgeBuildBadgeActionthat shows the build is being kept.static classRun.RedirectUpclassRun.RunExecutionObject that lives while the build is executed, to keep track of things that are needed only during the build.protected classRun.RunnerDeprecated.as of 1.467 Please useRun.RunExecutionstatic classRun.RunnerAbortedExceptionUsed inRun.RunExecution.run(hudson.model.BuildListener)to indicates that a fatal error in a build is reported toBuildListenerand the build should be simply aborted without further recording a stack trace.static classRun.StatusSummarizerUsed to implementgetBuildStatusSummary().static classRun.Summary-
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
Fields Modifier and Type Field Description static PermissionARTIFACTSprotected StringcharsetCharset in which the log file is written.static PermissionDELETEprotected StringdescriptionHuman-readable description which is used on the main build page.protected longdurationNumber of milli-seconds it took to run this build.static FeedAdapter<Run>FEED_ADAPTERFeedAdapterto produce feed from the summary of this build.static FeedAdapter<Run>FEED_ADAPTER_LATESTFeedAdapterto produce feeds to show one build per project.static intLIST_CUTOFFMaximum number of artifacts to list before using switching to the tree view.protected RunTnextBuildNext build.intnumberBuild number.static Comparator<Run>ORDER_BY_DATESort by date.static PermissionGroupPERMISSIONSprotected RunTpreviousBuildPrevious build.protected JobTprojectstatic longQUEUE_ID_UNKNOWNThe originalQueue.Item.getId()has not yet been mapped onto theRuninstance.protected ResultresultThe build result.static booleanSKIP_PERMISSION_CHECKEscape hatch for StaplerProxy-based access controlprotected longtimestampWhen the build is scheduled.static PermissionUPDATEstatic com.thoughtworks.xstream.XStreamXSTREAMstatic XStream2XSTREAM2
-
Constructor Summary
Constructors Modifier Constructor Description protectedRun(JobT job)Creates a newRun.protectedRun(JobT job, long timestamp)protectedRun(JobT project, File buildDir)Loads a run from a log file.protectedRun(JobT job, Calendar timestamp)Constructor for creating aRunobject in an arbitrary state.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected RunT_this()Obtains 'this' in a more type safe signature.voidaddAction(Action a)Adds a new action.booleancanToggleLogKeep()Checks whether keep status can be toggled.intcompareTo(RunT that)Ordering based on build numbers.protected BuildReference<RunT>createReference()Called byRunMapto obtain a reference to this run.voiddelete()Deletes this build and its entire logvoiddeleteArtifacts()Deletes this build's artifacts.DirectoryBrowserSupportdoArtifact()Serves the artifacts.voiddoBuildNumber(org.kohsuke.stapler.StaplerResponse rsp)Returns the build number in the body.voiddoBuildStatus(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)voiddoBuildTimestamp(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, String format)Returns the build time stamp in the body.org.kohsuke.stapler.HttpResponsedoConfigSubmit(org.kohsuke.stapler.StaplerRequest req)voiddoConsoleText(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)Sends out the raw console output.voiddoDoDelete(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)Deletes the build when the button is pressed.voiddoProgressiveLog(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)Deprecated.as of 1.352 UsegetLogText().doProgressiveText(req,rsp)voiddoSubmitDescription(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)Accepts the new description.voiddoToggleLogKeep(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)protected voiddropLinks()Called byRunMapto drop bi-directional links in preparation for deleting a build.protected voidexecute(Run.RunExecution job)static Run<?,?>fromExternalizableId(String id)Tries to find a run from an persisted identifier.StringgetAbsoluteUrl()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.ACLgetACL()Obtains the ACL associated with this object.ApigetApi()ArtifactManagergetArtifactManager()Gets an object responsible for storing and retrieving build artifacts.List<Run.Artifact>getArtifacts()Gets the artifacts (relative togetArtifactsDir().FilegetArtifactsDir()Deprecated.Should only be used fromStandardArtifactManageror subclasses.List<Run.Artifact>getArtifactsUpTo(int artifactsNumber)Gets the first N artifacts.List<BuildBadgeAction>getBadgeActions()Gets the subset ofActionable.getActions()that consists ofBuildBadgeActions.Collection<Fingerprint>getBuildFingerprints()get the fingerprints associated with this buildprotected List<RunT>getBuildsOverThreshold(int numberOfBuilds, Result threshold)Returns the lastnumberOfBuildsbuilds with a build result ≥threshold.StringgetBuildStatusIconClassName()Run.SummarygetBuildStatusSummary()Gets an object which represents the single line summary of the status of this build (especially in comparison with the previous build.)StringgetBuildStatusUrl()<T extends Cause>
TgetCause(Class<T> type)Returns aCauseof a particular type.List<Cause>getCauses()Returns theCauses that triggered a build.EnvVarsgetCharacteristicEnvVars()Builds up the environment variable map that's sufficient to identify a process as ours.CharsetgetCharset()Gets the charset in which the log file is written.StringgetDescription()StringgetDisplayName()longgetDuration()Gets the millisecond it took to build.StringgetDurationString()Gets the string that says how long the build took to run.ObjectgetDynamic(String token, org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)EnvVarsgetEnvironment()Deprecated.as of 1.305 usegetEnvironment(TaskListener)EnvVarsgetEnvironment(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 UsegetEnvironment(TaskListener)instead.longgetEstimatedDuration()Returns the estimated duration for this run if it is currently running.ExecutorgetExecutor()Gets theExecutorbuilding this job, if it's being built.StringgetExternalizableId()Produces an identifier for this run unique in the system.StringgetFullDisplayName()booleangetHasArtifacts()Check if theRuncontains artifacts.BallColorgetIconColor()Gets the icon color for display.StringgetId()Unique ID of this build.StringgetLog()Deprecated.since 2007-11-11.List<String>getLog(int maxLines)Gets the log of the build as a list of strings (one per log line).FilegetLogFile()Deprecated.Assumes file-based storage of the log, which is not necessarily the case for Pipelines after JEP-210.InputStreamgetLogInputStream()Returns an input stream that reads from the log file.ReadergetLogReader()AnnotatedLargeTextgetLogText()Used to URL-bindAnnotatedLargeText.RunTgetNextBuild()intgetNumber()ExecutorgetOneOffExecutor()Gets the one offExecutorbuilding this job, if it's being built.JobTgetParent()The project this build is for.RunTgetPreviousBuild()RunTgetPreviousBuildInProgress()Obtains the next younger build in progress.List<RunT>getPreviousBuildsOverThreshold(int numberOfBuilds, Result threshold)Returns the lastnumberOfBuildsbuilds with a build result ≥threshold.RunTgetPreviousBuiltBuild()Returns the last build that was actually built - i.e., skipping any with Result.NOT_BUILTRunTgetPreviousCompletedBuild()Gets the most recent completed build excluding 'this' Run itself.RunTgetPreviousFailedBuild()Returns the last failed build before this build.RunTgetPreviousNotFailedBuild()Returns the last build that didn't fail before this build.RunTgetPreviousSuccessfulBuild()Returns the last successful build before this build.longgetQueueId()Get theQueue.Item.getId()of the original queue item from where this Run instance originated.ResultgetResult()Returns the build result.FilegetRootDir()Get the root directory of thisRunon the controller.StringgetSearchUrl()Returns the URL of this item relative to the parentSearchItem.longgetStartTimeInMillis()When the build has started running in an executor.ObjectgetTarget()DategetTime()Same asgetTimestamp()but in a different type.longgetTimeInMillis()Same asgetTimestamp()but in a different type, that is since the time of the epoch.CalendargetTimestamp()When the build is scheduled.StringgetTimestampString()Gets the string that says how long since this build has started.StringgetTimestampString2()Returns the timestamp formatted in xs:dateTime.List<Action>getTransientActions()Deprecated.UseActionable.getAllActions()instead.StringgetTruncatedDescription()Deprecated.truncated description based on theTRUNCATED_DESCRIPTION_LIMITsetting.StringgetUrl()Returns the URL of thisRun, relative to the context root of Hudson.StringgetWhyKeepLog()IfisKeepLog()returns true, returns a short, human-readable sentence that explains why it's being kept.booleanhasCustomDisplayName()booleanhasntStartedYet()Returns true if the build is still queued and hasn't started yet.booleanisBuilding()Returns true if the build is not completed yet.booleanisInProgress()Determine whether the run is being build right now.booleanisKeepLog()Returns true if this build should be kept and not deleted.booleanisLogUpdated()Returns true if the log file is still being updated.voidkeepLog()Marks this build to be kept.voidkeepLog(boolean newValue)protected SearchIndexBuildermakeSearchIndex()Default implementation that returns empty index.protected voidonEndBuilding()Called when a job finished building normally or abnormally.protected voidonLoad()Called after the build is loaded and the object is added to the build list.protected voidonStartBuilding()Called when a job started building.ArtifactManagerpickArtifactManager()Selects an object responsible for storing and retrieving build artifacts.voidreload()Reloads the build record from disk.protected voidrun(Run.Runner job)Deprecated.as of 1.467 Useexecute(hudson.model.Run.RunExecution)voidsave()Save the settings to a file.voidsetDescription(String description)voidsetDisplayName(String value)voidsetQueueId(long queueId)Set the queue item ID.voidsetResult(Result r)Sets thegetResult()of this build.protected voidsubmit(net.sf.json.JSONObject json)StringtoString()voidupdateSymlinks(TaskListener listener)Deprecated.After JENKINS-37862 this no longer does anything.voidwriteLogTo(long offset, org.apache.commons.jelly.XMLOutput out)Used fromconsole.jellyto write annotated log to the given output.protected ObjectwriteReplace()voidwriteWholeLogTo(OutputStream out)Writes the complete log from the start to finish to theOutputStream.-
Methods inherited from class hudson.model.Actionable
addOrReplaceAction, 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
-
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
-
-
-
-
Field Detail
-
QUEUE_ID_UNKNOWN
public static final long QUEUE_ID_UNKNOWN
The originalQueue.Item.getId()has not yet been mapped onto theRuninstance.- Since:
- 1.601
- See Also:
- Constant Field Values
-
number
public transient int number
Build 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> previousBuild
Previous 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> nextBuild
Next build. Can be null. External code should usegetNextBuild()
-
timestamp
protected long timestamp
When the build is scheduled.
-
result
protected volatile Result result
The build result. This value may change while the state is inRun.State.BUILDING.
-
description
@CheckForNull protected volatile String 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.getTruncatedDescription()may be used to retrieve a size-limited description, but it implies some limitations.
-
duration
protected long duration
Number of milli-seconds it took to run this build.
-
charset
protected String 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:
getCharset()
-
LIST_CUTOFF
public static final int LIST_CUTOFF
Maximum number of artifacts to list before using switching to the tree view.
-
XSTREAM
public static final com.thoughtworks.xstream.XStream XSTREAM
-
XSTREAM2
public static final XStream2 XSTREAM2
-
ORDER_BY_DATE
public static final Comparator<Run> ORDER_BY_DATE
Sort by date. Newer ones first.
-
FEED_ADAPTER
public static final FeedAdapter<Run> FEED_ADAPTER
FeedAdapterto produce feed from the summary of this build.
-
FEED_ADAPTER_LATEST
public static final FeedAdapter<Run> FEED_ADAPTER_LATEST
FeedAdapterto produce feeds to show one build per project.
-
PERMISSIONS
public static final PermissionGroup PERMISSIONS
-
DELETE
public static final Permission DELETE
-
UPDATE
public static final Permission UPDATE
-
ARTIFACTS
public static final Permission ARTIFACTS
-
SKIP_PERMISSION_CHECK
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static boolean SKIP_PERMISSION_CHECK
Escape hatch for StaplerProxy-based access control
-
-
Constructor Detail
-
Run
protected Run(@NonNull JobT job) throws IOExceptionCreates a newRun.- Parameters:
job- Owner job- Throws:
IOException- See Also:
LazyBuildMixIn.newBuild()
-
Run
protected Run(@NonNull JobT job, @NonNull Calendar timestamp)Constructor for creating aRunobject in an arbitrary state.numbermust be set manually.May be used in a
SubTask.createExecutable()(instead of callingLazyBuildMixIn.newBuild()). For example,MatrixConfiguration.newBuilddoes this so that thetimestampas well asnumberare shared with the parent build.
-
Run
protected Run(@NonNull JobT job, long timestamp)- See Also:
Run(Job, Calendar)
-
Run
protected Run(@NonNull JobT project, @NonNull File buildDir) throws IOExceptionLoads a run from a log file.- Throws:
IOException- See Also:
LazyBuildMixIn.loadBuild(java.io.File)
-
-
Method Detail
-
reload
public void reload() throws IOExceptionReloads 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 public List<Action> 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
public void addAction(@NonNull Action a)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 ARunAction2is handled specially.- Overrides:
addActionin classActionable
-
_this
@NonNull protected RunT _this()
Obtains 'this' in a more type safe signature.
-
compareTo
public int compareTo(@NonNull RunT that)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 this Run instance originated.- 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
@Exported @CheckForNull public Result getResult()
Returns the build result.When a build is
in progress, this method returns an intermediate result.- 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
public void setResult(@NonNull Result r)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
@NonNull public List<BuildBadgeAction> getBadgeActions()
Gets the subset ofActionable.getActions()that consists ofBuildBadgeActions.
-
isBuilding
@Exported public boolean isBuilding()
Returns true if the build is not completed yet. This includes "not started yet" state.
-
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
@Exported @CheckForNull public Executor getExecutor()
Gets theExecutorbuilding this job, if it's being built. Otherwise null. This method looks forExecutorwho'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 toRunsome more time even after the build is finished (for example to perform post-production processing.)
-
getOneOffExecutor
@CheckForNull public Executor getOneOffExecutor()
Gets the one offExecutorbuilding this job, if it's being built. Otherwise null.- Since:
- 1.433
-
getCharset
@NonNull public final Charset getCharset()
Gets the charset in which the log file is written.- Returns:
- never null.
- Since:
- 1.257
-
getCauses
@NonNull public List<Cause> getCauses()
Returns theCauses 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
@CheckForNull public <T extends Cause> T getCause(Class<T> type)
Returns aCauseof 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
@CheckForNull public String getWhyKeepLog()
IfisKeepLog()returns true, returns a short, human-readable sentence that explains why it's being kept.
-
getParent
@NonNull public JobT getParent()
The project this build is for.
-
getTimestamp
@Exported @NonNull public Calendar getTimestamp()
When the build is scheduled.- See Also:
getStartTimeInMillis()
-
getTime
@NonNull public final Date 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:
getTimestamp()
-
getDescription
@Exported @CheckForNull public String getDescription()
-
getTruncatedDescription
@Deprecated @CheckForNull public String getTruncatedDescription()
Deprecated.truncated description based on theTRUNCATED_DESCRIPTION_LIMITsetting.Returns the length-limited description. The method tries to take HTML tags within the description into account, but it is a best-effort attempt. Also, the method will likely not work properly if a non-HTMLMarkupFormatteris used.- Returns:
- The length-limited description.
-
getTimestampString
@NonNull public String getTimestampString()
Gets the string that says how long since this build has started.- Returns:
- string like "3 minutes" "1 day" etc.
-
getTimestampString2
@NonNull public String getTimestampString2()
Returns the timestamp formatted in xs:dateTime.
-
getDurationString
@NonNull public String getDurationString()
Gets the string that says how long the build took to run.
-
getDuration
@Exported public long getDuration()
Gets the millisecond it took to build.
-
getIconColor
@NonNull public BallColor getIconColor()
Gets the icon color for display.
-
hasntStartedYet
public boolean hasntStartedYet()
Returns true if the build is still queued and hasn't started yet.
-
getFullDisplayName
@Exported public String getFullDisplayName()
-
getDisplayName
@Exported public String getDisplayName()
- Specified by:
getDisplayNamein interfaceModelObject
-
hasCustomDisplayName
public boolean hasCustomDisplayName()
-
setDisplayName
public void setDisplayName(String value) throws IOException
- Parameters:
value- Set to null to revert back to the default "#NNN".- Throws:
IOException
-
getNumber
@Exported(visibility=2) public int getNumber()
-
createReference
@NonNull protected BuildReference<RunT> createReference()
Called byRunMapto obtain a reference to this run.- Returns:
- Reference to the build. Never null
- Since:
- 1.556
- See Also:
LazyBuildMixIn.RunMixIn.createReference()
-
dropLinks
protected void dropLinks()
Called byRunMapto drop bi-directional links in preparation for deleting a build.- Since:
- 1.556
- See Also:
LazyBuildMixIn.RunMixIn.dropLinks()
-
getPreviousBuild
@CheckForNull public RunT getPreviousBuild()
-
getPreviousCompletedBuild
@CheckForNull public final RunT getPreviousCompletedBuild()
Gets the most recent completed build excluding 'this' Run itself.
-
getPreviousBuildInProgress
@CheckForNull public final RunT 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
@CheckForNull public RunT getPreviousBuiltBuild()
Returns the last build that was actually built - i.e., skipping any with Result.NOT_BUILT
-
getPreviousNotFailedBuild
@CheckForNull public RunT getPreviousNotFailedBuild()
Returns the last build that didn't fail before this build.
-
getPreviousFailedBuild
@CheckForNull public RunT getPreviousFailedBuild()
Returns the last failed build before this build.
-
getPreviousSuccessfulBuild
@CheckForNull public RunT 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 lastnumberOfBuildsbuilds 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
@NonNull protected List<RunT> getBuildsOverThreshold(int numberOfBuilds, @NonNull Result threshold)
Returns the lastnumberOfBuildsbuilds 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
@CheckForNull public RunT getNextBuild()
- See Also:
LazyBuildMixIn.RunMixIn.getNextBuild()
-
getUrl
@NonNull public String getUrl()
Returns the URL of thisRun, relative to the context root of Hudson.- Returns:
- String like "job/foo/32/" with trailing slash but no leading slash.
-
getAbsoluteUrl
@Exported(visibility=2, name="url") @Deprecated @NonNull public final 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.Obtains the absolute URL to this build.
-
getSearchUrl
@NonNull public final String getSearchUrl()
Description copied from interface:SearchItemReturns the URL of this item relative to the parentSearchItem.- Specified by:
getSearchUrlin 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
@Exported @NonNull public String getId()
Unique ID of this build. Usually the decimal form ofnumber, but may be a formatted timestamp for historical builds.
-
getRootDir
@NonNull public File getRootDir()
Get the root directory of thisRunon the controller. Files related to thisRunshould be stored below this directory.- Specified by:
getRootDirin interfacePersistenceRoot- Returns:
- Root directory of this
Runon the controller. Never null
-
getArtifactManager
@NonNull public final ArtifactManager 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)StandardArtifactManageris 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
@NonNull public final ArtifactManager pickArtifactManager() throws IOException
Selects an object responsible for storing and retrieving build artifacts. The first time this is called on a running build,ArtifactManagerConfigurationis 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,StandardArtifactManageris 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 public File getArtifactsDir()
Deprecated.Should only be used fromStandardArtifactManageror subclasses.Gets the directory where the artifacts are archived.
-
getArtifacts
@Exported @NonNull public List<Run.Artifact> getArtifacts()
Gets the artifacts (relative togetArtifactsDir().- Returns:
- The list can be empty but never null
-
getArtifactsUpTo
@NonNull public List<Run.Artifact> getArtifactsUpTo(int artifactsNumber)
Gets the first N artifacts.- Returns:
- The list can be empty but never null
-
getHasArtifacts
public boolean getHasArtifacts()
Check if theRuncontains 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 @NonNull public File 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
@NonNull public InputStream getLogInputStream() throws IOException
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
@NonNull public Reader getLogReader() throws IOException
- Throws:
IOException
-
writeLogTo
public void writeLogTo(long offset, @NonNull org.apache.commons.jelly.XMLOutput out) throws IOExceptionUsed fromconsole.jellyto write annotated log to the given output.- Throws:
IOException- Since:
- 1.349
-
writeWholeLogTo
public void writeWholeLogTo(@NonNull OutputStream out) throws IOException, InterruptedExceptionWrites 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:
IOExceptionInterruptedException
-
getLogText
@NonNull public AnnotatedLargeText getLogText()
Used to URL-bindAnnotatedLargeText.- Returns:
- A
Runlog with annotations
-
makeSearchIndex
@NonNull protected SearchIndexBuilder makeSearchIndex()
Description copied from class:AbstractModelObjectDefault implementation that returns empty index.- Overrides:
makeSearchIndexin classAbstractModelObject
-
getApi
@NonNull public Api getApi()
-
getACL
@NonNull public ACL getACL()
Description copied from interface:AccessControlledObtains the ACL associated with this object.- Specified by:
getACLin interfaceAccessControlled- Returns:
- never null.
-
deleteArtifacts
public void deleteArtifacts() throws IOExceptionDeletes this build's artifacts.- Throws:
IOException- if we fail to delete.- Since:
- 1.350
-
delete
public void delete() throws IOExceptionDeletes this build and its entire log- Throws:
IOException- if we fail to delete.
-
run
@Deprecated protected final void run(@NonNull Run.Runner job)
Deprecated.as of 1.467 Useexecute(hudson.model.Run.RunExecution)
-
execute
protected final void execute(@NonNull Run.RunExecution job)
-
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
public void save() throws IOExceptionSave the settings to a file.- Specified by:
savein interfaceSaveable- Throws:
IOException- if the persistence failed.
-
writeReplace
protected Object writeReplace()
-
getLog
@Deprecated @NonNull public String getLog() throws IOException
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
@NonNull public List<String> getLog(int maxLines) throws IOException
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.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException- Throws:
IOException
-
getBuildStatusUrl
@NonNull public String getBuildStatusUrl()
-
getBuildStatusIconClassName
public String getBuildStatusIconClassName()
-
getBuildStatusSummary
@NonNull public 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.)- See Also:
Run.StatusSummarizer
-
doArtifact
@NonNull public DirectoryBrowserSupport doArtifact()
Serves the artifacts.- Throws:
org.springframework.security.access.AccessDeniedException- Access denied
-
doBuildNumber
public void doBuildNumber(org.kohsuke.stapler.StaplerResponse rsp) throws IOExceptionReturns the build number in the body.- Throws:
IOException
-
doBuildTimestamp
public void doBuildTimestamp(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, @QueryParameter String format) throws IOExceptionReturns the build time stamp in the body.- Throws:
IOException
-
doConsoleText
public void doConsoleText(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOExceptionSends out the raw console output.- 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.StaplerRequest, org.kohsuke.stapler.StaplerResponse)andkeepLog(boolean)andkeepLog()are options - Since:
- 1.510
-
doToggleLogKeep
public void doToggleLogKeep(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException- Throws:
IOExceptionjavax.servlet.ServletException
-
keepLog
@CLIMethod(name="keep-build") public final void keepLog() throws IOException
Marks this build to be kept.- Throws:
IOException
-
keepLog
public void keepLog(boolean newValue) throws IOException- Throws:
IOException
-
doDoDelete
public void doDoDelete(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletExceptionDeletes the build when the button is pressed.- Throws:
IOExceptionjavax.servlet.ServletException
-
setDescription
public void setDescription(String description) throws IOException
- Throws:
IOException
-
doSubmitDescription
public void doSubmitDescription(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletExceptionAccepts the new description.- Throws:
IOExceptionjavax.servlet.ServletException
-
getEnvVars
@Deprecated public Map<String,String> getEnvVars()
Deprecated.as of 1.292 UsegetEnvironment(TaskListener)instead.
-
getEnvironment
@Deprecated public EnvVars getEnvironment() throws IOException, InterruptedException
Deprecated.as of 1.305 usegetEnvironment(TaskListener)- Throws:
IOExceptionInterruptedException
-
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.BuildSteps that invoke external processes should use this. This allowsBuildWrappers 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:
IOExceptionInterruptedException- Since:
- 1.305
-
getCharacteristicEnvVars
@NonNull public final EnvVars 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
@NonNull public String getExternalizableId()
Produces an identifier for this run unique in the system.- Returns:
- the
AbstractItem.getFullName(), then#, thengetNumber() - See Also:
fromExternalizableId(java.lang.String)
-
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.StaplerRequest req) throws IOException, javax.servlet.ServletException, Descriptor.FormException- Throws:
IOExceptionjavax.servlet.ServletExceptionDescriptor.FormException
-
submit
protected void submit(net.sf.json.JSONObject json) throws IOException- Throws:
IOException
-
getDynamic
public Object getDynamic(String token, org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
- Overrides:
getDynamicin classActionable
-
getTarget
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public Object getTarget()
- Specified by:
getTargetin interfaceorg.kohsuke.stapler.StaplerProxy
-
-