public class CustomVariableContextImpl extends Object implements CustomVariableContext
| Constructor and Description |
|---|
CustomVariableContextImpl(VariableSubstitutorFactory variableSubstitutorFactory) |
| Modifier and Type | Method and Description |
|---|---|
void |
addCustomData(String key,
String value)
Adds a
VariableType.MANUAL variable to ThreadLocal state. |
void |
clearContext()
Clear
ThreadLocal state. |
@NotNull Set<String> |
findAllVariables(@Nullable String variable)
Given a string, and a
Map of variables (variable -> value), all patterns in the string array
matching ${bamboo.<variable>} will be substituted with the value. |
Map<String,VariableDefinitionContext> |
getBuildInRepositoryVariablesIfBuildContext()
Return variables all built-in variables produced by repository plugin for the current build context.
|
@NotNull Map<String,VariableSubstitutionContext> |
getSubstitutedVariables()
Get all the variables that have previously been substituted in this thread.
|
@NotNull Map<String,VariableDefinitionContext> |
getVariableContexts()
Get all variables from current thread local context.
|
@NotNull VariableSubstitutorFactory |
getVariableSubstitutorFactory() |
@NotNull String |
removeAllVariables(@NotNull String value)
Given a string array, remove all variable patterns.
|
void |
setPlan(@NotNull ImmutablePlan plan)
Sets Plan reference and default variable definitions (globals and from plan) in
ThreadLocal state. |
String |
substituteString(String value)
Substitutes variables in the input string with their values using data from existing
ThreadLocal state. |
<V,E1 extends Exception,E2 extends Exception,E3 extends Exception> |
withVariableSubstitutor(@NotNull VariableSubstitutor variableSubstitutor,
BambooCallables.ThrowingX<V,E1,E2,E3> callable)
Run operation with provided
VariableSubstitutor in thread local context. |
<V> V |
withVariableSubstitutor(@NotNull VariableSubstitutor variableSubstitutor,
@NotNull Callable<V> callable)
Run operation with provided
VariableSubstitutor in thread local context. |
void |
withVariableSubstitutor(@NotNull VariableSubstitutor variableSubstitutor,
@NotNull Runnable runnable)
Run operation with provided
VariableSubstitutor in thread local context. |
<V> V |
withVariableSubstitutor(@NotNull VariableSubstitutor variableSubstitutor,
@NotNull Supplier<V> supplier)
Run operation with provided
VariableSubstitutor in thread local context. |
public CustomVariableContextImpl(VariableSubstitutorFactory variableSubstitutorFactory)
@NotNull public @NotNull Map<String,VariableSubstitutionContext> getSubstitutedVariables()
CustomVariableContextgetSubstitutedVariables in interface CustomVariableContextpublic void addCustomData(String key, String value)
CustomVariableContextVariableType.MANUAL variable to ThreadLocal state.addCustomData in interface CustomVariableContextkey - name of the variablevalue - value of the variablepublic String substituteString(String value)
CustomVariableContextThreadLocal state.substituteString in interface CustomVariableContextvalue - input stringpublic void setPlan(@NotNull
@NotNull ImmutablePlan plan)
CustomVariableContextThreadLocal state.
Clears history of substituted variables (CustomVariableContext.getSubstitutedVariables()setPlan in interface CustomVariableContextpublic void clearContext()
CustomVariableContextThreadLocal state.clearContext in interface CustomVariableContext@NotNull public @NotNull String removeAllVariables(@NotNull @NotNull String value)
removeAllVariables in interface CustomVariableContextvalue - string values to be analyzed@NotNull public @NotNull Set<String> findAllVariables(@Nullable @Nullable String variable)
Map of variables (variable -> value), all patterns in the string array
matching ${bamboo.<variable>} will be substituted with the value.findAllVariables in interface CustomVariableContextvariable - String value to be analyzed@NotNull public @NotNull Map<String,VariableDefinitionContext> getVariableContexts()
CustomVariableContextgetVariableContexts in interface CustomVariableContextpublic Map<String,VariableDefinitionContext> getBuildInRepositoryVariablesIfBuildContext()
CustomVariableContextBuildContext, otherwise returned map will be empty.
Note: variables are used in repository definition, they will be resolved according to current state of the CustomVariableContextgetBuildInRepositoryVariablesIfBuildContext in interface CustomVariableContext@NotNull public @NotNull VariableSubstitutorFactory getVariableSubstitutorFactory()
getVariableSubstitutorFactory in interface CustomVariableContextVariableSubstitutorpublic void withVariableSubstitutor(@NotNull
@NotNull VariableSubstitutor variableSubstitutor,
@NotNull
@NotNull Runnable runnable)
CustomVariableContextVariableSubstitutor in thread local context. Restore current thread local state when finished.withVariableSubstitutor in interface CustomVariableContextpublic <V> V withVariableSubstitutor(@NotNull
@NotNull VariableSubstitutor variableSubstitutor,
@NotNull
@NotNull Callable<V> callable)
throws Exception
CustomVariableContextVariableSubstitutor in thread local context. Restore current thread local state when finished.withVariableSubstitutor in interface CustomVariableContextExceptionpublic <V> V withVariableSubstitutor(@NotNull
@NotNull VariableSubstitutor variableSubstitutor,
@NotNull
@NotNull Supplier<V> supplier)
CustomVariableContextVariableSubstitutor in thread local context. Restore current thread local state when finished.withVariableSubstitutor in interface CustomVariableContextpublic <V,E1 extends Exception,E2 extends Exception,E3 extends Exception> V withVariableSubstitutor(@NotNull @NotNull VariableSubstitutor variableSubstitutor, @NotNull BambooCallables.ThrowingX<V,E1,E2,E3> callable) throws E1 extends Exception, E2 extends Exception, E3 extends Exception
CustomVariableContextVariableSubstitutor in thread local context. Restore current thread local state when finished.withVariableSubstitutor in interface CustomVariableContextE1 extends ExceptionCopyright © 2022 Atlassian Software Systems Pty Ltd. All rights reserved.