Class CheckPoint
- java.lang.Object
-
- hudson.model.CheckPoint
-
public final class CheckPoint extends Object
Provides a mechanism for synchronizing build executions in the face of concurrent builds.At certain points of a build,
BuildSteps and other extension points often need to refer to what happened in its earlier build. For example, aSCMcheck out can run concurrently, but the changelog computation requires that the check out of the earlier build has completed. Or if Hudson is sending out an e-mail, he needs to know the result of the previous build, so that he can decide an e-mail is necessary or not.Check pointing is a primitive mechanism to provide this sort of synchronization. These methods can be only invoked from
Executorthreads.Each
CheckPointinstance represents unique check points.CheckPointinstances are normally created as a static instance, because two builds of the same project needs to refer to the same check point instance for synchronization to happen properly.This class defines a few well-known check point instances. plugins can define their additional check points for their own use.
Note that not all job types support checkpoints.
Example
JUnitResultArchiverprovides a good example of how aRecordercan depend on its earlier result.- Since:
- 1.319
- Author:
- Kohsuke Kawaguchi
- See Also:
BuildStep.getRequiredMonitorService()
-
-
Field Summary
Fields Modifier and Type Field Description static CheckPointCOMPLETEDCheckPointthat indicates that the build is completed.static CheckPointCULPRITS_DETERMINEDCheckPointthat indicates thatAbstractBuild.getCulprits()is computed.static CheckPointMAIN_COMPLETEDCheckPointthat indicates that the build has finished executing the "main" portion (Builders in case ofFreeStyleProject) and now moving on to the post-build steps.
-
Constructor Summary
Constructors Constructor Description CheckPoint(String internalName)CheckPoint(String internalName, Object identity)For advanced uses.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidblock()Waits until the previous build in progress reaches a check point, identified by the given identifier, or until the current executor becomes the youngest build in progress.voidblock(BuildListener listener, String waiter)Likeblock()but allows for richer logging.booleanequals(Object that)inthashCode()voidreport()Records that the execution of the build has reached to a check point, identified by the given identifier.StringtoString()
-
-
-
Field Detail
-
CULPRITS_DETERMINED
public static final CheckPoint CULPRITS_DETERMINED
CheckPointthat indicates thatAbstractBuild.getCulprits()is computed.
-
COMPLETED
public static final CheckPoint COMPLETED
CheckPointthat indicates that the build is completed. (Run.isBuilding()==false)
-
MAIN_COMPLETED
public static final CheckPoint MAIN_COMPLETED
CheckPointthat indicates that the build has finished executing the "main" portion (Builders in case ofFreeStyleProject) and now moving on to the post-build steps.
-
-
Constructor Detail
-
CheckPoint
public CheckPoint(String internalName, Object identity)
For advanced uses. Creates a check point that uses the given object as its identity.
-
CheckPoint
public CheckPoint(String internalName)
- Parameters:
internalName- Name of this check point that's used in the logging, stack traces, debug messages, and so on. This is not displayed to users. No need for i18n.
-
-
Method Detail
-
report
public void report()
Records that the execution of the build has reached to a check point, identified by the given identifier.If the successive builds are waiting for this check point, they'll be released.
This method can be only called from an
Executorthread.
-
block
public void block() throws InterruptedExceptionWaits until the previous build in progress reaches a check point, identified by the given identifier, or until the current executor becomes the youngest build in progress.Note that "previous build in progress" should be interpreted as "previous (build in progress)" instead of "(previous build) if it's in progress". This makes a difference around builds that are aborted or failed very early without reporting the check points. Imagine the following time sequence:
- Build #1, #2, and #3 happens around the same time
- Build #3 waits for check point
JUnitResultArchiver - Build #2 aborts before getting to that check point
- Build #1 finally checks in
JUnitResultArchiver
Using this method, build #3 correctly waits until the step 4. Because of this behavior, the
report()/block()pair can normally be used without a try/finally block.This method can be only called from an
Executorthread.- Throws:
InterruptedException- If the build (represented by the calling executor thread) is aborted while it's waiting.
-
block
public void block(@NonNull BuildListener listener, @NonNull String waiter) throws InterruptedExceptionLikeblock()but allows for richer logging.- Parameters:
listener- an optional listener to whichwaiter- a description of what component is requesting the wait, such asDescriptor.getDisplayName()- Throws:
InterruptedException- if the build is aborted while waiting- Since:
- 1.528
-
-