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 Details

    • addCustomData

      void addCustomData(String key, String value)
      Adds a VariableType.MANUAL variable to ThreadLocal state.
      Parameters:
      key - name of the variable
      value - 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 existing ThreadLocal state.
      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)
      Sets Plan reference and default variable definitions (globals and from plan) in ThreadLocal state. Clears history of substituted variables (getSubstitutedVariables()
      Parameters:
      plan -
      Since:
      5.6
    • clearContext

      @Deprecated void clearContext()
      Clear ThreadLocal state.
    • 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 contain BuildContext, otherwise returned map will be empty. Note: variables are used in repository definition, they will be resolved according to current state of the CustomVariableContext
      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 provided VariableSubstitutor 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 provided VariableSubstitutor 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 provided VariableSubstitutor in 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, E2, E3
      Run operation with provided VariableSubstitutor in thread local context. Restore current thread local state when finished.
      Throws:
      E1 extends Exception
      E2 extends Exception
      E3 extends Exception
      Since:
      5.15