java.lang.Object
java.lang.Enum<CounterKey>
com.tikal.jenkins.plugins.multijob.counters.CounterKey
All Implemented Interfaces:
Serializable, Comparable<CounterKey>

public enum CounterKey extends Enum<CounterKey>
These are the keys of the counters that we will manage to report at phase level and multijob project level.

Every time a phase ends:

  1. We inject phase variables with the count of the jobs, one for every key.
  2. We update multijob variables with the number (counter) of the jobs, one for every key.

We can use these new variables at job condition, so we can write now conditions as follows (of course, these new variables are available in the next phase):

  • ${PHASE_SUCCESSFUL} > 1: The number of SUCCESSFUL jobs are greater than 1.
  • ${PHASE_ABORTED} == 0 || ${PHASE_UNSTABLE} == 2: The number of ABORTED jobs are equals to 0, or the number of UNSTABLE jobs are equals to 2.
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    The name of the new build variable which stores the number of aborted jobs.
    The name of the new build variable which stores the number of failed jobs.
    The name of the new build variable which stores the number of skipped jobs.
    The name of the new build variable which stores the number of successful jobs.
    The name of the new build variable which stores the number of successful jobs.
    The name of the new build variable which stores the number of unstable jobs.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String[]
    A convenient static array of all multijob and phase keys.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract boolean
    appliesTo(Result result)
    Checks if a result applies to the CounterKey.
    Returns the name of the key associated with the multijob project and the counterKey.
    Returns the name of the key associated with the phase and the counterKey.
    static CounterKey
    A convenient way to encapsulate logic to avoid an IllegalArgumentException when we need to find a CounterKey value and the key doesn't exists.
    static CounterKey
    Returns the enum constant of this type with the specified name.
    static CounterKey[]
    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

    • SUCCESSFUL

      public static final CounterKey SUCCESSFUL
      The name of the new build variable which stores the number of successful jobs. In this context, the SUCCESSFUL state means SUCCESS OR UNSTABLE results.
    • STABLE

      public static final CounterKey STABLE
      The name of the new build variable which stores the number of successful jobs. In this context, the STABLE state means SUCESS results.
    • UNSTABLE

      public static final CounterKey UNSTABLE
      The name of the new build variable which stores the number of unstable jobs. In this context, the UNSTABLE state means the UNSTABLE result.
    • FAILED

      public static final CounterKey FAILED
      The name of the new build variable which stores the number of failed jobs. In this context, the FAILED state means FAILED results.
    • ABORTED

      public static final CounterKey ABORTED
      The name of the new build variable which stores the number of aborted jobs. In this context, the ABORTED state means the ABORTED result.
    • SKIPPED

      public static final CounterKey SKIPPED
      The name of the new build variable which stores the number of skipped jobs. In this context, the SKIPPED state means the SKIPPED jobs.
  • Field Details

    • KEYS

      public static final String[] KEYS
      A convenient static array of all multijob and phase keys.
  • Method Details

    • values

      public static CounterKey[] 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 CounterKey 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
    • appliesTo

      public abstract boolean appliesTo(Result result)
      Checks if a result applies to the CounterKey. Every time a job has finished we must update the counter or counters this result applies to. This methods reports if the result applies to the CounterKey.
      Parameters:
      result - the Result of the job that we checked if applies to the CounterKey.
      Returns:
      true when the result applies to the counterKey, false if not applies.
      See Also:
    • getMultiJobKey

      public String getMultiJobKey()
      Returns the name of the key associated with the multijob project and the counterKey.
      Returns:
      a String with the name of key that will be used to store the counter.
    • getPhaseKey

      public String getPhaseKey()
      Returns the name of the key associated with the phase and the counterKey.
      Returns:
      a String with the name of key that will be used to store the counter.
    • safetyValueOf

      public static CounterKey safetyValueOf(String key)
      A convenient way to encapsulate logic to avoid an IllegalArgumentException when we need to find a CounterKey value and the key doesn't exists.
      Parameters:
      key - the name of the CounterKey that we want to search.
      Returns:
      the CounterKey or null if it doesn't exists.