Enum CredentialsScope

java.lang.Object
java.lang.Enum<CredentialsScope>
com.cloudbees.plugins.credentials.CredentialsScope
All Implemented Interfaces:
Serializable, Comparable<CredentialsScope>

public enum CredentialsScope extends Enum<CredentialsScope> implements Serializable
The scope of credentials.
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    This credential is available to the object on which the credential is associated and all objects that are children of that object.
    This credential is only available to the object on which the credential is associated.
    This credential is available to the user which which the credential is associated.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract String
    Gets the display name for the credentials.
    abstract boolean
    Tests if credentials with this scope are visible in the supplied context.
    Returns the enum constant of this type with the specified name.
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Enum

    clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • SYSTEM

      public static final CredentialsScope SYSTEM
      This credential is only available to the object on which the credential is associated. Typically you would use SYSTEM scoped credentials for things like email auth, agent connection, etc, i.e. where the Jenkins instance itself is using the credential.
    • GLOBAL

      public static final CredentialsScope GLOBAL
      This credential is available to the object on which the credential is associated and all objects that are children of that object. Typically you would use GLOBAL scoped credentials for things that are needed by Jobs.
    • USER

      public static final CredentialsScope USER
      This credential is available to the user which which the credential is associated. Typically you would use USER scoped credentials where credentials are required for immediate actions. Some examples could include:
      • Tag this build
      • Deploy artifacts to some container NOW
      • etc
      The key point is that the user is making a request and instructing Jenkins to use one of their own credentials in the scope of the request. Where the request is something that happens automatically, e.g. a build triggered by SCM polling, then USER scoped credentials are not usually appropriate (unless the action is one that can fail gracefully)

      Another way of looking at this is, if the action is one that is configured from the Job's Configure page, then don't use USER scope, as that prevents another user from modifying the job configuration (because they will only be able to see their own credentials)

  • Method Details

    • values

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

      public static CredentialsScope valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified name
      NullPointerException - if the argument is null
    • getDisplayName

      public abstract String getDisplayName()
      Gets the display name for the credentials.
      Returns:
      The display name for the credentials.
    • isVisible

      public abstract boolean isVisible(ModelObject context)
      Tests if credentials with this scope are visible in the supplied context.
      Parameters:
      context - the context.
      Returns:
      true if credentials with this scope are visible in the supplied context.
      Since:
      2.1.5