Class BuildCleanupContextImpl
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.cleanup.BuildCleanupContextImpl
-
- All Implemented Interfaces:
BuildCleanupContext
,BuildCleanupContextEx
,CleanupContext
,ErrorReporter
public final class BuildCleanupContextImpl extends Object implements BuildCleanupContextEx, ErrorReporter
-
-
Constructor Summary
Constructors Constructor Description BuildCleanupContextImpl(CleanupLevel cleanupLevel, List<SFinishedBuild> builds, CleanupProcessStateEx cleanupState, KeepBuildDataProvider keepBuildDataProvider, DBBuildHistory buildHistory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildCleanupError(long buildId, String errorMessage)
Notify the core cleanup process about an error happened in a cleanup extension.List<SFinishedBuild>
getBuilds()
Returns list of builds to be cleaned on given cleanup level if such builds still exist.CleanupLevel
getCleanupLevel()
CleanupPolicy
getCleanupPolicyForBuild(long buildId)
This method is intended for TeamCity internal usage only and can be changed, removed or throw an exception at any time!
Always returns the cleanup policy with "do not clean anything" artifacts pattern.CleanupProcessStateEx
getCleanupState()
ErrorReporter
getErrorReporter()
Object
getExtensionData(String key)
Retrieves the data stored by an extension for a provided key.KeepBuildData
getKeepBuildData(SFinishedBuild build)
Provides the build data to preserve.Set<Long>
getProblematicBuildsIds()
void
onBuildCleanupError(BuildsCleanupExtension cleanupExtension, SBuild build, String errorMessage)
Informs the core clean-up process about an error happened in a clean-up extension.
Note: if there are a lot of such calls, try to keep the sameerrorMessage
when possible: it will allow to provide the resulting health report in a more compact format.void
setExtensionData(String key, Object data)
A method that can be used by aBuildsCleanupExtension
to store data in the current cleanup context.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jetbrains.buildServer.serverSide.cleanup.BuildCleanupContext
getBuildIds
-
-
-
-
Constructor Detail
-
BuildCleanupContextImpl
public BuildCleanupContextImpl(@NotNull CleanupLevel cleanupLevel, @NotNull List<SFinishedBuild> builds, @NotNull CleanupProcessStateEx cleanupState, @NotNull KeepBuildDataProvider keepBuildDataProvider, @NotNull DBBuildHistory buildHistory)
-
-
Method Detail
-
getCleanupLevel
@NotNull public CleanupLevel getCleanupLevel()
- Specified by:
getCleanupLevel
in interfaceBuildCleanupContext
- Returns:
- current cleanup level
-
getBuilds
@NotNull public List<SFinishedBuild> getBuilds()
Description copied from interface:BuildCleanupContext
Returns list of builds to be cleaned on given cleanup level if such builds still exist.- Specified by:
getBuilds
in interfaceBuildCleanupContext
-
getErrorReporter
@NotNull public ErrorReporter getErrorReporter()
- Specified by:
getErrorReporter
in interfaceBuildCleanupContext
- Returns:
- error reporter which can be used if errors occur during the cleanup.
-
buildCleanupError
public void buildCleanupError(long buildId, @NotNull String errorMessage)
Description copied from interface:ErrorReporter
Notify the core cleanup process about an error happened in a cleanup extension.- Specified by:
buildCleanupError
in interfaceErrorReporter
-
onBuildCleanupError
public void onBuildCleanupError(@NotNull BuildsCleanupExtension cleanupExtension, @NotNull SBuild build, @NotNull String errorMessage)
Description copied from interface:BuildCleanupContext
Informs the core clean-up process about an error happened in a clean-up extension.
Note: if there are a lot of such calls, try to keep the sameerrorMessage
when possible: it will allow to provide the resulting health report in a more compact format.- Specified by:
onBuildCleanupError
in interfaceBuildCleanupContext
- Parameters:
cleanupExtension
- the affected clean-up extensionbuild
- the affected builderrorMessage
- the error description
-
getExtensionData
@Nullable public Object getExtensionData(@NotNull String key)
Description copied from interface:BuildCleanupContext
Retrieves the data stored by an extension for a provided key.- Specified by:
getExtensionData
in interfaceBuildCleanupContext
- Parameters:
key
- a unique key that identifies saved object. Suggested naming convention: 'extension_class_name.extension_specific_data_key' (Example: `jetbrains.buildServer.serverSide.impl.CustomDataStorageManagerImpl.SUFFIXES_CACHE`).- Returns:
- data stored by an extension in this context by means of
BuildCleanupContext.setExtensionData(String, Object)
invocation.
-
setExtensionData
public void setExtensionData(@NotNull String key, @NotNull Object data)
Description copied from interface:BuildCleanupContext
A method that can be used by aBuildsCleanupExtension
to store data in the current cleanup context.- Specified by:
setExtensionData
in interfaceBuildCleanupContext
- Parameters:
key
- a unique key that identifies saved object. Suggested naming convention: 'extension_class_name.extension_specific_data_key' (Example: * `jetbrains.buildServer.serverSide.impl.CustomDataStorageManagerImpl.SUFFIXES_CACHE`).data
- data to be stored for the provided key.
-
getProblematicBuildsIds
@NotNull public Set<Long> getProblematicBuildsIds()
- Specified by:
getProblematicBuildsIds
in interfaceBuildCleanupContextEx
- Returns:
- the set of builds ids for errors reported via
BuildCleanupContext.onBuildCleanupError(BuildsCleanupExtension, SBuild, String)
orErrorReporter
-
getCleanupState
@NotNull public CleanupProcessStateEx getCleanupState()
- Specified by:
getCleanupState
in interfaceBuildCleanupContextEx
- Specified by:
getCleanupState
in interfaceCleanupContext
- Returns:
- current cleanup state
-
getCleanupPolicyForBuild
@NotNull public CleanupPolicy getCleanupPolicyForBuild(long buildId)
Description copied from interface:BuildCleanupContext
This method is intended for TeamCity internal usage only and can be changed, removed or throw an exception at any time!
Always returns the cleanup policy with "do not clean anything" artifacts pattern.- Specified by:
getCleanupPolicyForBuild
in interfaceBuildCleanupContext
- Parameters:
buildId
- id of the build
-
getKeepBuildData
@NotNull public KeepBuildData getKeepBuildData(@NotNull SFinishedBuild build)
Description copied from interface:BuildCleanupContextEx
Provides the build data to preserve.- Specified by:
getKeepBuildData
in interfaceBuildCleanupContextEx
- Parameters:
build
- a build fromBuildCleanupContext.getBuilds()
- Returns:
- build data to preserve
-
-