Class ItemPathResolver
java.lang.Object
hudson.plugins.promoted_builds.util.ItemPathResolver
Implements an engine, which allows to resolve
Item
s by their paths.
The engine supports both relative and absolute addressing.- Since:
- 2.22
- Author:
- Oleg Nenashev
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
External manager, which allows the alter behavior on-demand. -
Constructor Summary
-
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.ResolverManager
s and falls back toENABLE_LEGACY_RESOLUTION_AGAINST_ROOT
if 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 anItem
of 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 theItem
to be retrieved- Parameters:
path
- Path string to the item.baseItem
- BaseItem
for the relative addressing. If null, this addressing approach will be skippedtype
- Type of theItem
to 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
-