Class ItemPathResolver
java.lang.Object
hudson.plugins.promoted_builds.util.ItemPathResolver
Implements an engine, which allows to resolve
Items by their paths.
The engine supports both relative and absolute addressing.- Since:
- 2.22
- Author:
- Oleg Nenashev
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classExternal manager, which allows the alter behavior on-demand. -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ItemPathResolver
public ItemPathResolver()
-
-
Method Details
-
isEnableLegacyResolutionAgainstRoot
public static boolean isEnableLegacyResolutionAgainstRoot()Check if the legacy path resolution mode is enabled. The resolution uses availableItemPathResolver.ResolverManagers and falls back toENABLE_LEGACY_RESOLUTION_AGAINST_ROOTif there is no decision.- Returns:
- True if the legacy resolution engine is enabled
-
getByPath
@CheckForNull @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static <T extends Item> T getByPath(@NonNull String path, @CheckForNull Item baseItem, @NonNull Class<T> type) Gets anItemof the specified type by absolute or relative path.The implementation retains the original behavior in
Effectively, the resolution order is following:PromotedBuildParameterDefinition, but this method also provides a support of multi-level addressing including special markups for the relative addressing.- Optional Legacy behavior, which can be enabled by
ENABLE_LEGACY_RESOLUTION_AGAINST_ROOT. If an item for the name exists on the top Jenkins level, it will be returned - If the path starts with "/", a global addressing will be used
- If the path starts with "./" or "../", a relative addressing will be used
- If there is no prefix, a relative addressing will be tried. If it fails, the method falls back to a global one
null.- Type Parameters:
T- Type of theItemto be retrieved- Parameters:
path- Path string to the item.baseItem- BaseItemfor the relative addressing. If null, this addressing approach will be skippedtype- Type of theItemto be retrieved- Returns:
- Found
Item. Null if it has not been found by all addressing modes or the type differs.
- Optional Legacy behavior, which can be enabled by
-