Package com.atlassian.bamboo.variable
Class CustomVariableContextImpl
- java.lang.Object
-
- com.atlassian.bamboo.variable.CustomVariableContextImpl
-
- All Implemented Interfaces:
CustomVariableContext
public class CustomVariableContextImpl extends Object implements CustomVariableContext
-
-
Constructor Summary
Constructors Constructor Description CustomVariableContextImpl(VariableSubstitutorFactory variableSubstitutorFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCustomData(String key, String value)Adds aVariableType.MANUALvariable toThreadLocalstate.voidclearContext()ClearThreadLocalstate.@NotNull Set<String>findAllVariables(@Nullable String variable)Given a string, and aMapof 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 VariableSubstitutorFactorygetVariableSubstitutorFactory()@NotNull StringremoveAllVariables(@NotNull String value)Given a string array, remove all variable patterns.voidsetPlan(@NotNull ImmutablePlan plan)Sets Plan reference and default variable definitions (globals and from plan) inThreadLocalstate.StringsubstituteString(String value)Substitutes variables in the input string with their values using data from existingThreadLocalstate.voidwithVariableSubstitutor(@NotNull VariableSubstitutor variableSubstitutor, @NotNull Runnable runnable)Run operation with providedVariableSubstitutorin thread local context.<V> VwithVariableSubstitutor(@NotNull VariableSubstitutor variableSubstitutor, @NotNull Callable<V> callable)Run operation with providedVariableSubstitutorin thread local context.<V> VwithVariableSubstitutor(@NotNull VariableSubstitutor variableSubstitutor, @NotNull Supplier<V> supplier)Run operation with providedVariableSubstitutorin 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 providedVariableSubstitutorin thread local context.
-
-
-
Constructor Detail
-
CustomVariableContextImpl
public CustomVariableContextImpl(VariableSubstitutorFactory variableSubstitutorFactory)
-
-
Method Detail
-
getSubstitutedVariables
@NotNull public @NotNull Map<String,VariableSubstitutionContext> getSubstitutedVariables()
Description copied from interface:CustomVariableContextGet all the variables that have previously been substituted in this thread.- Specified by:
getSubstitutedVariablesin interfaceCustomVariableContext- Returns:
-
addCustomData
public void addCustomData(String key, String value)
Description copied from interface:CustomVariableContextAdds aVariableType.MANUALvariable toThreadLocalstate.- Specified by:
addCustomDatain interfaceCustomVariableContext- Parameters:
key- name of the variablevalue- value of the variable
-
substituteString
public String substituteString(String value)
Description copied from interface:CustomVariableContextSubstitutes variables in the input string with their values using data from existingThreadLocalstate.- Specified by:
substituteStringin interfaceCustomVariableContext- Parameters:
value- input string- Returns:
- substituted string
-
setPlan
public void setPlan(@NotNull @NotNull ImmutablePlan plan)Description copied from interface:CustomVariableContextSets Plan reference and default variable definitions (globals and from plan) inThreadLocalstate. Clears history of substituted variables (CustomVariableContext.getSubstitutedVariables()- Specified by:
setPlanin interfaceCustomVariableContext
-
clearContext
public void clearContext()
Description copied from interface:CustomVariableContextClearThreadLocalstate.- Specified by:
clearContextin interfaceCustomVariableContext
-
removeAllVariables
@NotNull public @NotNull String removeAllVariables(@NotNull @NotNull String value)
Given a string array, remove all variable patterns.- Specified by:
removeAllVariablesin interfaceCustomVariableContext- Parameters:
value- string values to be analyzed- Returns:
- value with variables removed
-
findAllVariables
@NotNull public @NotNull Set<String> findAllVariables(@Nullable @Nullable String variable)
Given a string, and aMapof variables (variable -> value), all patterns in the string array matching ${bamboo.<variable>} will be substituted with the value.- Specified by:
findAllVariablesin interfaceCustomVariableContext- Parameters:
variable- String value to be analyzed- Returns:
- Array of string values with variables extrapolated
-
getVariableContexts
@NotNull public @NotNull Map<String,VariableDefinitionContext> getVariableContexts()
Description copied from interface:CustomVariableContextGet all variables from current thread local context.- Specified by:
getVariableContextsin interfaceCustomVariableContext- Returns:
- mapping between variable keys and contexts
-
getBuildInRepositoryVariablesIfBuildContext
public Map<String,VariableDefinitionContext> getBuildInRepositoryVariablesIfBuildContext()
Description copied from interface:CustomVariableContextReturn 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:
getBuildInRepositoryVariablesIfBuildContextin interfaceCustomVariableContext
-
getVariableSubstitutorFactory
@NotNull public @NotNull VariableSubstitutorFactory getVariableSubstitutorFactory()
- Specified by:
getVariableSubstitutorFactoryin interfaceCustomVariableContext- Returns:
- factory for
VariableSubstitutor
-
withVariableSubstitutor
public void withVariableSubstitutor(@NotNull @NotNull VariableSubstitutor variableSubstitutor, @NotNull @NotNull Runnable runnable)Description copied from interface:CustomVariableContextRun operation with providedVariableSubstitutorin thread local context. Restore current thread local state when finished.- Specified by:
withVariableSubstitutorin interfaceCustomVariableContext
-
withVariableSubstitutor
public <V> V withVariableSubstitutor(@NotNull @NotNull VariableSubstitutor variableSubstitutor, @NotNull @NotNull Callable<V> callable) throws ExceptionDescription copied from interface:CustomVariableContextRun operation with providedVariableSubstitutorin thread local context. Restore current thread local state when finished.- Specified by:
withVariableSubstitutorin interfaceCustomVariableContext- Throws:
Exception
-
withVariableSubstitutor
public <V> V withVariableSubstitutor(@NotNull @NotNull VariableSubstitutor variableSubstitutor, @NotNull @NotNull Supplier<V> supplier)Description copied from interface:CustomVariableContextRun operation with providedVariableSubstitutorin thread local context. Restore current thread local state when finished.- Specified by:
withVariableSubstitutorin 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:CustomVariableContextRun operation with providedVariableSubstitutorin thread local context. Restore current thread local state when finished.- Specified by:
withVariableSubstitutorin interfaceCustomVariableContext- Throws:
E1 extends Exception
-
-