Package com.atlassian.bamboo.variable
Interface CustomVariableContext
- All Known Implementing Classes:
CustomVariableContextForTests
,CustomVariableContextImpl
@PublicApi
public interface CustomVariableContext
Bean maintaining
ThreadLocal
state of available variables.
The state contains (if applicable):
- current Plan
- variable definitions (including Plan variables when applicable)
- BuildContext
- BuildLogger
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCustomData
(String key, String value) Adds aVariableType.MANUAL
variable toThreadLocal
state.void
Deprecated.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> Return variables all built-in variables produced by repository plugin for the current build context.@NotNull Map<String,
VariableSubstitutionContext> Get all the variables that have previously been substituted in this thread.@NotNull Map<String,
VariableDefinitionContext> Get all variables from current thread local context.@NotNull VariableSubstitutorFactory
@NotNull String
removeAllVariables
(@NotNull String unparsedString) Given a string, remove all variable patterns.void
setPlan
(@NotNull ImmutablePlan plan) Deprecated.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.withVariableSubstitutor
(@NotNull VariableSubstitutor variableSubstitutor, BambooCallables.ThrowingX<V, E1, E2, E3> callable) Run operation with providedVariableSubstitutor
in thread local context.
-
Method Details
-
addCustomData
Adds aVariableType.MANUAL
variable toThreadLocal
state.- Parameters:
key
- name of the variablevalue
- value of the variable
-
substituteString
Substitutes variables in the input string with their values using data from existingThreadLocal
state.- Parameters:
value
- input string- Returns:
- substituted string
-
getVariableContexts
Get all variables from current thread local context.- Returns:
- mapping between variable keys and contexts
- Since:
- 5.9
-
removeAllVariables
Given a string, remove all variable patterns.- Parameters:
unparsedString
- string values to be analyzed- Returns:
- value with variables removed
-
getSubstitutedVariables
Get all the variables that have previously been substituted in this thread.- Returns:
-
setPlan
Deprecated.Sets Plan reference and default variable definitions (globals and from plan) inThreadLocal
state. Clears history of substituted variables (getSubstitutedVariables()
- Parameters:
plan
-- Since:
- 5.6
-
clearContext
Deprecated.ClearThreadLocal
state. -
findAllVariables
Given a string, all patterns in the string matching ${bamboo.<variable>} or ${system.<variable>} will be found.- Parameters:
stringWithVariables
- String value to be analyzed- Returns:
- Array of string values with variables extrapolated
-
getBuildInRepositoryVariablesIfBuildContext
@NotNull @NotNull Map<String,VariableDefinitionContext> getBuildInRepositoryVariablesIfBuildContext()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
- Since:
- 5.9
-
getVariableSubstitutorFactory
- Returns:
- factory for
VariableSubstitutor
- Since:
- 5.9
-
withVariableSubstitutor
void withVariableSubstitutor(@NotNull @NotNull VariableSubstitutor variableSubstitutor, @NotNull @NotNull Runnable runnable) Run operation with providedVariableSubstitutor
in thread local context. Restore current thread local state when finished.- Since:
- 5.9
-
withVariableSubstitutor
<V> V withVariableSubstitutor(@NotNull @NotNull VariableSubstitutor variableSubstitutor, @NotNull @NotNull Callable<V> callable) throws Exception Run operation with providedVariableSubstitutor
in thread local context. Restore current thread local state when finished.- Throws:
Exception
- Since:
- 5.9
-
withVariableSubstitutor
<V> V withVariableSubstitutor(@NotNull @NotNull VariableSubstitutor variableSubstitutor, @NotNull @NotNull Supplier<V> supplier) Run operation with providedVariableSubstitutor
in thread local context. Restore current thread local state when finished.- Since:
- 5.9
-
withVariableSubstitutor
<V,E1 extends Exception, V withVariableSubstitutorE2 extends Exception, E3 extends Exception> (@NotNull @NotNull VariableSubstitutor variableSubstitutor, @NotNull BambooCallables.ThrowingX<V, E1, throws E1, E2, E3E2, E3> callable) Run operation with providedVariableSubstitutor
in thread local context. Restore current thread local state when finished.
-
CustomVariableContextRunner
orwithVariableSubstitutor(VariableSubstitutor, Runnable)