Class ParameterExpander


  • public class ParameterExpander
    extends Object
    Expands a parameterized string to its full potential.
    Author:
    Robert Sandell <robert.sandell@sonyericsson.com>
    • Field Detail

      • DEFAULT_PARAMETERS_COUNT

        public static final int DEFAULT_PARAMETERS_COUNT
        How many default parameters there are (plus one) to initialize the size of the parameters-map.
        See Also:
        Constant Field Values
      • MESSAGE_DELIMITER

        public static final String MESSAGE_DELIMITER
        The delimiter used to separate build URLs from their messages.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ParameterExpander

        public ParameterExpander​(IGerritHudsonTriggerConfig config,
                                 Jenkins jenkins)
        Constructor.
        Parameters:
        config - the global config.
        jenkins - the Hudson instance.
      • ParameterExpander

        public ParameterExpander​(IGerritHudsonTriggerConfig config)
        Constructor.
        Parameters:
        config - the global config.
    • Method Detail

      • getBuildStartedCommand

        public String getBuildStartedCommand​(Run r,
                                             TaskListener taskListener,
                                             com.sonymobile.tools.gerrit.gerritevents.dto.events.ChangeBasedEvent event,
                                             BuildsStartedStats stats)
        Gets the expanded string to send to Gerrit for a build-started event.
        Parameters:
        r - the build.
        taskListener - the taskListener.
        event - the event.
        stats - the statistics.
        Returns:
        the "expanded" command string.
      • getCodeReviewValue

        protected Integer getCodeReviewValue​(Result res,
                                             GerritTrigger trigger)
        Finds the code review value for the specified build result on the configured trigger.
        Parameters:
        res - the build result.
        trigger - the trigger that might have overridden values.
        Returns:
        the value.
      • getVerifiedValue

        protected Integer getVerifiedValue​(Result res,
                                           GerritTrigger trigger)
        Finds the verified value for the specified build result on the configured trigger.
        Parameters:
        res - the build result.
        trigger - the trigger that might have overridden values.
        Returns:
        the value.
      • getMinimumVerifiedValue

        @CheckForNull
        public Integer getMinimumVerifiedValue​(BuildMemory.MemoryImprint memoryImprint,
                                               boolean onlyBuilt,
                                               Integer maxAllowedVerifiedValue)
        Returns the minimum verified value for the build results in the memory. If no builds have contributed to verified value, this method returns null
        Parameters:
        memoryImprint - the memory.
        onlyBuilt - only count builds that completed (no NOT_BUILT builds)
        maxAllowedVerifiedValue - Upper boundary on verified value.
        Returns:
        the lowest verified value.
      • getMinimumCodeReviewValue

        @CheckForNull
        public Integer getMinimumCodeReviewValue​(BuildMemory.MemoryImprint memoryImprint,
                                                 boolean onlyBuilt)
        Returns the minimum code review value for the build results in the memory. If no builds have contributed to code review value, this method returns null
        Parameters:
        memoryImprint - the memory
        onlyBuilt - only count builds that completed (no NOT_BUILT builds)
        Returns:
        the lowest code review value.
      • getHighestNotificationLevel

        public com.sonymobile.tools.gerrit.gerritevents.dto.rest.Notify getHighestNotificationLevel​(BuildMemory.MemoryImprint memoryImprint,
                                                                                                    boolean onlyBuilt)
        Returns the highest configured notification level.
        Parameters:
        memoryImprint - the memory
        onlyBuilt - only count builds that completed (no NOT_BUILT builds)
        Returns:
        the highest configured notification level.
      • getNotificationLevel

        public com.sonymobile.tools.gerrit.gerritevents.dto.rest.Notify getNotificationLevel​(GerritTrigger trigger)
        Returns the notification level value for the given trigger.
        Parameters:
        trigger - the trigger.
        Returns:
        the level value.
      • getBuildCompletedCommand

        public String getBuildCompletedCommand​(BuildMemory.MemoryImprint memoryImprint,
                                               TaskListener listener,
                                               com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent gerritEvent)
        Gets the "expanded" build completed command to send to gerrit.
        Parameters:
        memoryImprint - the memory with all the information
        listener - the taskListener
        gerritEvent - the event.
        Returns:
        the command.
      • getBuildCompletedMessage

        public String getBuildCompletedMessage​(BuildMemory.MemoryImprint memoryImprint,
                                               TaskListener listener)
        Returns cover message to be send after build has been completed.
        Parameters:
        memoryImprint - memory
        listener - listener
        Returns:
        the message for the build completed command.
      • getBuildStartedMessage

        public String getBuildStartedMessage​(Run build,
                                             TaskListener listener,
                                             com.sonymobile.tools.gerrit.gerritevents.dto.events.ChangeBasedEvent event,
                                             BuildsStartedStats stats)
        Returns cover message to be send after build has been started.
        Parameters:
        build - build
        listener - listener
        event - event
        stats - stats
        Returns:
        the message for the build started command.
      • findMessage

        protected String findMessage​(String completedCommand)
        Finds the --message part of the command. TODO Solve it in a better way
        Parameters:
        completedCommand - the command
        Returns:
        the message