public class CustomVariableContextForTests extends Object implements CustomVariableContext
| Constructor and Description |
|---|
CustomVariableContextForTests() |
| 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. |
Set<String> |
findAllVariables(String stringWithVariables)
Given a string, all patterns in the string matching ${bamboo.<variable>} or ${system.<variable>} will be found.
|
Map<String,VariableDefinitionContext> |
getBuildInRepositoryVariablesIfBuildContext()
Return variables all built-in variables produced by repository plugin for the current build context.
|
Map<String,VariableSubstitutionContext> |
getSubstitutedVariables()
Get all the variables that have previously been substituted in this thread.
|
Map<String,VariableDefinitionContext> |
getVariableContexts()
Get all variables from current thread local context.
|
Map<String,VariableDefinitionContext> |
getVariableContexts(CommonContext commonContext)
Get all variables from context.
|
Map<String,String> |
getVariables(CommonContext commonContext)
Get all variables from context.
|
VariableSubstitutorFactory |
getVariableSubstitutorFactory() |
String |
removeAllVariables(String unparsedString)
Given a string, remove all variable patterns.
|
void |
setCommonContext(CommonContext commonContext)
Set context reference in
ThreadLocal state. |
void |
setPlan(ImmutablePlan plan)
Sets Plan reference and default variable definitions (globals and from plan) in
ThreadLocal state. |
void |
setPlan(ImmutablePlan plan,
Map<String,VariableDefinitionContext> variablesContextMap)
Sets Plan reference and variable definitions in
ThreadLocal state. |
void |
setPlan(PlanIdentifier plan,
Map<String,VariableDefinitionContext> variablesContextMap)
Sets Plan reference and variable definitions in
ThreadLocal state. |
void |
setVariables(Map<String,VariableDefinitionContext> variablesContextMap)
Set variable definitions in
ThreadLocal state. |
String |
substituteString(String value)
Substitutes variables in the input string with their values using data from existing
ThreadLocal state. |
String |
substituteString(String value,
CommonContext commonContext,
BuildLogger buildLogger)
Substitutes variables in the input string with their values using provided data, i.e.
|
<V> V |
withVariableSubstitutor(VariableSubstitutor variableSubstitutor,
Callable<V> callable)
Run operation with provided
VariableSubstitutor in thread local context. |
void |
withVariableSubstitutor(VariableSubstitutor variableSubstitutor,
Runnable runnable)
Run operation with provided
VariableSubstitutor in thread local context. |
<V> V |
withVariableSubstitutor(VariableSubstitutor variableSubstitutor,
Supplier<V> supplier)
Run operation with provided
VariableSubstitutor in thread local context. |
public 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(@Nullable String value)
CustomVariableContextThreadLocal state.substituteString in interface CustomVariableContextvalue - input string@Nullable public String substituteString(@Nullable String value, @Nullable CommonContext commonContext, @Nullable BuildLogger buildLogger)
CustomVariableContextThreadLocal state.substituteString in interface CustomVariableContextvalue - input stringcommonContext - build contextbuildLogger - build logger@NotNull public Map<String,VariableDefinitionContext> getVariableContexts(@Nullable CommonContext commonContext)
CustomVariableContextgetVariableContexts in interface CustomVariableContextcommonContext - build or deployment context@NotNull public Map<String,VariableDefinitionContext> getVariableContexts()
CustomVariableContextgetVariableContexts in interface CustomVariableContext@NotNull public Map<String,String> getVariables(@Nullable CommonContext commonContext)
CustomVariableContextgetVariables in interface CustomVariableContextcommonContext - Build or Deployment context@NotNull public String removeAllVariables(@NotNull String unparsedString)
CustomVariableContextremoveAllVariables in interface CustomVariableContextunparsedString - string values to be analyzed@NotNull public Map<String,VariableSubstitutionContext> getSubstitutedVariables()
CustomVariableContextgetSubstitutedVariables in interface CustomVariableContextpublic void setCommonContext(@NotNull
CommonContext commonContext)
CustomVariableContextThreadLocal state.
Sets the variable definitions to those contained in the context.
context has priority over Plans and Deployment Jobs when resolving the variables.setCommonContext in interface CustomVariableContextpublic void clearContext()
CustomVariableContextThreadLocal state.clearContext in interface CustomVariableContextpublic void setPlan(@NotNull
PlanIdentifier plan,
@Nullable
Map<String,VariableDefinitionContext> variablesContextMap)
CustomVariableContextThreadLocal state.
Clears history of substituted variables (CustomVariableContext.getSubstitutedVariables()setPlan in interface CustomVariableContextvariablesContextMap - variable definitions (including plan variables)public void setPlan(@NotNull
ImmutablePlan plan,
@Nullable
Map<String,VariableDefinitionContext> variablesContextMap)
CustomVariableContextThreadLocal state.
Clears history of substituted variables (CustomVariableContext.getSubstitutedVariables()setPlan in interface CustomVariableContextvariablesContextMap - variable definitions (including plan variables)public void setPlan(@NotNull
ImmutablePlan plan)
CustomVariableContextThreadLocal state.
Clears history of substituted variables (CustomVariableContext.getSubstitutedVariables()setPlan in interface CustomVariableContextpublic void setVariables(Map<String,VariableDefinitionContext> variablesContextMap)
CustomVariableContextThreadLocal state.
Clears history of substituted variables (CustomVariableContext.getSubstitutedVariables()setVariables in interface CustomVariableContextvariablesContextMap - variable definitions@NotNull public Set<String> findAllVariables(@Nullable String stringWithVariables)
CustomVariableContextfindAllVariables in interface CustomVariableContextstringWithVariables - String value to be analyzed@NotNull public 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 VariableSubstitutorFactory getVariableSubstitutorFactory()
getVariableSubstitutorFactory in interface CustomVariableContextVariableSubstitutorpublic void withVariableSubstitutor(@NotNull
VariableSubstitutor variableSubstitutor,
@NotNull
Runnable runnable)
CustomVariableContextVariableSubstitutor in thread local context. Restore current thread local state when finished.withVariableSubstitutor in interface CustomVariableContextpublic <V> V withVariableSubstitutor(@NotNull
VariableSubstitutor variableSubstitutor,
@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
VariableSubstitutor variableSubstitutor,
@NotNull
Supplier<V> supplier)
CustomVariableContextVariableSubstitutor in thread local context. Restore current thread local state when finished.withVariableSubstitutor in interface CustomVariableContextCopyright © 2017 Atlassian Software Systems Pty Ltd. All rights reserved.