Class ParameterExpander
java.lang.Object
com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier.ParameterExpander
Expands a parameterized string to its full potential.
- Author:
- Robert Sandell <robert.sandell@sonyericsson.com>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intHow many default parameters there are (plus one) to initialize the size of the parameters-map.static final StringThe delimiter used to separate build URLs from their messages. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.ParameterExpander(IGerritHudsonTriggerConfig config, Jenkins jenkins) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringfindMessage(String completedCommand) Finds the --message part of the command.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.getBuildCompletedMessage(BuildMemory.MemoryImprint memoryImprint, TaskListener listener) Returns cover message to be send after build has been completed.Finds the code review vote for build started of the specified build.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.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.Finds the verified vote for build started of the specified build.protected IntegergetCodeReviewValue(Result res, GerritTrigger trigger) Finds the code review value for the specified build result on the configured trigger.com.sonymobile.tools.gerrit.gerritevents.dto.rest.NotifygetHighestNotificationLevel(BuildMemory.MemoryImprint memoryImprint, boolean onlyBuilt) Returns the highest configured notification level.getMinimumCodeReviewValue(BuildMemory.MemoryImprint memoryImprint, boolean onlyBuilt) Returns the minimum code review value for the build results in the memory.getMinimumVerifiedValue(BuildMemory.MemoryImprint memoryImprint, boolean onlyBuilt, Integer maxAllowedVerifiedValue) Returns the minimum verified value for the build results in the memory.com.sonymobile.tools.gerrit.gerritevents.dto.rest.NotifygetNotificationLevel(GerritTrigger trigger) Returns the notification level value for the given trigger.protected IntegergetVerifiedValue(Result res, GerritTrigger trigger) Finds the verified value for the specified build result on the configured trigger.
-
Field Details
-
DEFAULT_PARAMETERS_COUNT
public static final int DEFAULT_PARAMETERS_COUNTHow many default parameters there are (plus one) to initialize the size of the parameters-map.- See Also:
-
MESSAGE_DELIMITER
The delimiter used to separate build URLs from their messages.- See Also:
-
-
Constructor Details
-
ParameterExpander
Constructor.- Parameters:
config- the global config.jenkins- the Hudson instance.
-
ParameterExpander
Constructor.- Parameters:
config- the global config.
-
-
Method Details
-
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.
-
getBuildStartedVerifiedValue
Finds the verified vote for build started of the specified build. If there is aGerritTriggerand it has aGerritTrigger.getGerritBuildStartedVerifiedValue()specified, that value will be used, otherwise the global config value inIGerritHudsonTriggerConfig.getGerritBuildStartedVerifiedValue()will be used.- Parameters:
r- the build.- Returns:
- the value.
-
getBuildStartedCodeReviewValue
Finds the code review vote for build started of the specified build. If there is aGerritTriggerand it has aGerritTrigger.getGerritBuildStartedCodeReviewValue()specified, that value will be used, otherwise the global config value inIGerritHudsonTriggerConfig.getGerritBuildStartedCodeReviewValue()will be used.- Parameters:
r- the build.- Returns:
- the value.
-
getCodeReviewValue
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
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 memoryonlyBuilt- 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 memoryonlyBuilt- 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 informationlistener- the taskListenergerritEvent- 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- memorylistener- 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- buildlistener- listenerevent- eventstats- stats- Returns:
- the message for the build started command.
-
findMessage
Finds the --message part of the command. TODO Solve it in a better way- Parameters:
completedCommand- the command- Returns:
- the message
-