Package com.atlassian.bamboo.variable
Interface CustomVariableContext
-
- All Known Implementing Classes:
CustomVariableContextForTests,CustomVariableContextImpl
@PublicApi public interface CustomVariableContextBean maintainingThreadLocalstate of available variables. The state contains (if applicable): - currentPlan- variable definitions (including Plan variables when applicable) -BuildContext-BuildLogger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidaddCustomData(String key, String value)Adds aVariableType.MANUALvariable toThreadLocalstate.voidclearContext()Deprecated.@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 VariableSubstitutorFactorygetVariableSubstitutorFactory()@NotNull StringremoveAllVariables(@NotNull String unparsedString)Given a string, remove all variable patterns.voidsetPlan(@NotNull ImmutablePlan plan)Deprecated.StringsubstituteString(@Nullable 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.
-
-
-
Method Detail
-
addCustomData
void addCustomData(String key, String value)
Adds aVariableType.MANUALvariable toThreadLocalstate.- Parameters:
key- name of the variablevalue- value of the variable
-
substituteString
@Contract("null -> null; !null -> !null") String substituteString(@Nullable @Nullable String value)Substitutes variables in the input string with their values using data from existingThreadLocalstate.- Parameters:
value- input string- Returns:
- substituted string
-
getVariableContexts
@NotNull @NotNull Map<String,VariableDefinitionContext> getVariableContexts()
Get all variables from current thread local context.- Returns:
- mapping between variable keys and contexts
- Since:
- 5.9
-
removeAllVariables
@NotNull @NotNull String removeAllVariables(@NotNull @NotNull String unparsedString)
Given a string, remove all variable patterns.- Parameters:
unparsedString- string values to be analyzed- Returns:
- value with variables removed
-
getSubstitutedVariables
@NotNull @NotNull Map<String,VariableSubstitutionContext> getSubstitutedVariables()
Get all the variables that have previously been substituted in this thread.- Returns:
-
setPlan
@Deprecated void setPlan(@NotNull @NotNull ImmutablePlan plan)
Deprecated.Sets Plan reference and default variable definitions (globals and from plan) inThreadLocalstate. Clears history of substituted variables (getSubstitutedVariables()- Parameters:
plan-- Since:
- 5.6
-
clearContext
@Deprecated void clearContext()
Deprecated.ClearThreadLocalstate.
-
findAllVariables
@NotNull @NotNull Set<String> findAllVariables(@Nullable @Nullable String stringWithVariables)
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
@NotNull @NotNull VariableSubstitutorFactory getVariableSubstitutorFactory()
- Returns:
- factory for
VariableSubstitutor - Since:
- 5.9
-
withVariableSubstitutor
void withVariableSubstitutor(@NotNull @NotNull VariableSubstitutor variableSubstitutor, @NotNull @NotNull Runnable runnable)Run operation with providedVariableSubstitutorin 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 ExceptionRun operation with providedVariableSubstitutorin 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 providedVariableSubstitutorin thread local context. Restore current thread local state when finished.- Since:
- 5.9
-
withVariableSubstitutor
<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
Run operation with providedVariableSubstitutorin thread local context. Restore current thread local state when finished.- Throws:
E1 extends Exception- Since:
- 5.15
-
-