Enum Class ParameterPolicy

java.lang.Object
java.lang.Enum<ParameterPolicy>
io.jenkins.plugins.multibranchparams.ParameterPolicy
All Implemented Interfaces:
Serializable, Comparable<ParameterPolicy>, Constable

public enum ParameterPolicy extends Enum<ParameterPolicy>
Controls how the Multibranch Params plugin interacts with parameters that a Jenkinsfile may declare via its own properties([parameters([...])]) block.

The plugin injects parameters at scan time; a Jenkinsfile's properties() call runs at build time and can overwrite that. This enum lets you choose the right trade-off for your pipeline.

Parameter policy behaviour
ModeAt scan timeAfter a Jenkinsfile build runs
REPLACE Always inject plugin params only, ignoring whatever is in the Jenkinsfile. Jenkinsfile can overwrite at build time; next scan restores plugin params.
MERGE_PLUGIN_WINS Combine both; on a name conflict the plugin's definition takes precedence. Jenkinsfile can overwrite; next scan merges again.
MERGE_JENKINSFILE_WINS Combine both; on a name conflict the Jenkinsfile's definition is kept. Jenkinsfile can overwrite; next scan merges again.
SKIP_IF_JENKINSFILE Inject only if the Jenkinsfile has not yet defined its own params. Once Jenkinsfile has set params, subsequent scans leave them untouched.
  • Enum Constant Details

    • REPLACE

      public static final ParameterPolicy REPLACE
      Always inject plugin-defined parameters at scan time, replacing whatever the job currently has (including params set by a prior Jenkinsfile build). This is the default.
    • MERGE_PLUGIN_WINS

      public static final ParameterPolicy MERGE_PLUGIN_WINS
      Merge plugin parameters with any parameters the Jenkinsfile already declared. Jenkinsfile-only params are preserved above the banner; on a name conflict the plugin's definition takes precedence.
    • MERGE_JENKINSFILE_WINS

      public static final ParameterPolicy MERGE_JENKINSFILE_WINS
      Merge plugin parameters with any parameters the Jenkinsfile already declared. Jenkinsfile params are kept as-is; plugin params are only added for names that the Jenkinsfile does not already define.
    • SKIP_IF_JENKINSFILE

      public static final ParameterPolicy SKIP_IF_JENKINSFILE
      Inject plugin parameters only when the job does not yet have parameters that were set by a Jenkinsfile build. Once a build has run and the Jenkinsfile's properties() call has stored its parameters, subsequent scans will leave those parameters untouched.

      Detection: the plugin marks its own injections with a MultiBranchHeaderParameter sentinel. If the current job has a ParametersDefinitionProperty that contains no such marker, the parameters are assumed to be Jenkinsfile-owned and are left alone.

  • Method Details

    • values

      public static ParameterPolicy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ParameterPolicy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null