Package com.atlassian.bamboo.variable
Class CustomVariableContextForTests
- java.lang.Object
-
- com.atlassian.bamboo.variable.CustomVariableContextForTests
-
- All Implemented Interfaces:
CustomVariableContext
public class CustomVariableContextForTests extends Object implements CustomVariableContext
-
-
Constructor Summary
Constructors Constructor Description CustomVariableContextForTests()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCustomData(String key, String value)
Adds aVariableType.MANUAL
variable toThreadLocal
state.void
clearContext()
ClearThreadLocal
state.@NotNull Set<String>
findAllVariables(@Nullable String stringWithVariables)
Given a string, all patterns in the string matching ${bamboo.<variable>} or ${system.<variable>} will be found.@NotNull 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 unparsedString)
Given a string, remove all variable patterns.void
setPlan(@NotNull ImmutablePlan plan)
Sets Plan reference and default variable definitions (globals and from plan) inThreadLocal
state.String
substituteString(@Nullable String value)
Substitutes variables in the input string with their values using data from existingThreadLocal
state.void
withVariableSubstitutor(@NotNull VariableSubstitutor variableSubstitutor, @NotNull Runnable runnable)
Run operation with providedVariableSubstitutor
in thread local context.<V> V
withVariableSubstitutor(@NotNull VariableSubstitutor variableSubstitutor, @NotNull Callable<V> callable)
Run operation with providedVariableSubstitutor
in thread local context.<V> V
withVariableSubstitutor(@NotNull VariableSubstitutor variableSubstitutor, @NotNull Supplier<V> supplier)
Run operation with providedVariableSubstitutor
in thread local context.<V,E1 extends Exception,E2 extends Exception,E3 extends Exception>
VwithVariableSubstitutor(@NotNull VariableSubstitutor variableSubstitutor, BambooCallables.ThrowingX<V,E1,E2,E3> callable)
Run operation with providedVariableSubstitutor
in thread local context.
-
-
-
Method Detail
-
addCustomData
public void addCustomData(String key, String value)
Description copied from interface:CustomVariableContext
Adds aVariableType.MANUAL
variable toThreadLocal
state.- Specified by:
addCustomData
in interfaceCustomVariableContext
- Parameters:
key
- name of the variablevalue
- value of the variable
-
substituteString
public String substituteString(@Nullable @Nullable String value)
Description copied from interface:CustomVariableContext
Substitutes variables in the input string with their values using data from existingThreadLocal
state.- Specified by:
substituteString
in interfaceCustomVariableContext
- Parameters:
value
- input string- Returns:
- substituted string
-
getVariableContexts
@NotNull public @NotNull Map<String,VariableDefinitionContext> getVariableContexts()
Description copied from interface:CustomVariableContext
Get all variables from current thread local context.- Specified by:
getVariableContexts
in interfaceCustomVariableContext
- Returns:
- mapping between variable keys and contexts
-
removeAllVariables
@NotNull public @NotNull String removeAllVariables(@NotNull @NotNull String unparsedString)
Description copied from interface:CustomVariableContext
Given a string, remove all variable patterns.- Specified by:
removeAllVariables
in interfaceCustomVariableContext
- Parameters:
unparsedString
- string values to be analyzed- Returns:
- value with variables removed
-
getSubstitutedVariables
@NotNull public @NotNull Map<String,VariableSubstitutionContext> getSubstitutedVariables()
Description copied from interface:CustomVariableContext
Get all the variables that have previously been substituted in this thread.- Specified by:
getSubstitutedVariables
in interfaceCustomVariableContext
- Returns:
-
findAllVariables
@NotNull public @NotNull Set<String> findAllVariables(@Nullable @Nullable String stringWithVariables)
Description copied from interface:CustomVariableContext
Given a string, all patterns in the string matching ${bamboo.<variable>} or ${system.<variable>} will be found.- Specified by:
findAllVariables
in interfaceCustomVariableContext
- Parameters:
stringWithVariables
- String value to be analyzed- Returns:
- Array of string values with variables extrapolated
-
getBuildInRepositoryVariablesIfBuildContext
@NotNull public @NotNull Map<String,VariableDefinitionContext> getBuildInRepositoryVariablesIfBuildContext()
Description copied from interface:CustomVariableContext
Return variables all built-in variables produced by repository plugin for the current build context. Current thread local state must containBuildContext
, otherwise returned map will be empty. Note: variables are used in repository definition, they will be resolved according to current state of theCustomVariableContext
- Specified by:
getBuildInRepositoryVariablesIfBuildContext
in interfaceCustomVariableContext
-
setPlan
public void setPlan(@NotNull @NotNull ImmutablePlan plan)
Description copied from interface:CustomVariableContext
Sets Plan reference and default variable definitions (globals and from plan) inThreadLocal
state. Clears history of substituted variables (CustomVariableContext.getSubstitutedVariables()
- Specified by:
setPlan
in interfaceCustomVariableContext
-
clearContext
public void clearContext()
Description copied from interface:CustomVariableContext
ClearThreadLocal
state.- Specified by:
clearContext
in interfaceCustomVariableContext
-
getVariableSubstitutorFactory
@NotNull public @NotNull VariableSubstitutorFactory getVariableSubstitutorFactory()
- Specified by:
getVariableSubstitutorFactory
in interfaceCustomVariableContext
- Returns:
- factory for
VariableSubstitutor
-
withVariableSubstitutor
public void withVariableSubstitutor(@NotNull @NotNull VariableSubstitutor variableSubstitutor, @NotNull @NotNull Runnable runnable)
Description copied from interface:CustomVariableContext
Run operation with providedVariableSubstitutor
in thread local context. Restore current thread local state when finished.- Specified by:
withVariableSubstitutor
in interfaceCustomVariableContext
-
withVariableSubstitutor
public <V> V withVariableSubstitutor(@NotNull @NotNull VariableSubstitutor variableSubstitutor, @NotNull @NotNull Callable<V> callable) throws Exception
Description copied from interface:CustomVariableContext
Run operation with providedVariableSubstitutor
in thread local context. Restore current thread local state when finished.- Specified by:
withVariableSubstitutor
in interfaceCustomVariableContext
- Throws:
Exception
-
withVariableSubstitutor
public <V> V withVariableSubstitutor(@NotNull @NotNull VariableSubstitutor variableSubstitutor, @NotNull @NotNull Supplier<V> supplier)
Description copied from interface:CustomVariableContext
Run operation with providedVariableSubstitutor
in thread local context. Restore current thread local state when finished.- Specified by:
withVariableSubstitutor
in interfaceCustomVariableContext
-
withVariableSubstitutor
public <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
Description copied from interface:CustomVariableContext
Run operation with providedVariableSubstitutor
in thread local context. Restore current thread local state when finished.- Specified by:
withVariableSubstitutor
in interfaceCustomVariableContext
- Throws:
E1 extends Exception
-
-