Class ParameterExpander
- java.lang.Object
-
- com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier.ParameterExpander
-
public class ParameterExpander extends Object
Expands a parameterized string to its full potential.- Author:
- Robert Sandell <robert.sandell@sonyericsson.com>
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_PARAMETERS_COUNT
How many default parameters there are (plus one) to initialize the size of the parameters-map.static String
MESSAGE_DELIMITER
The delimiter used to separate build URLs from their messages.
-
Constructor Summary
Constructors Constructor Description ParameterExpander(IGerritHudsonTriggerConfig config)
Constructor.ParameterExpander(IGerritHudsonTriggerConfig config, Jenkins jenkins)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
findMessage(String completedCommand)
Finds the --message part of the command.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.String
getBuildCompletedMessage(BuildMemory.MemoryImprint memoryImprint, TaskListener listener)
Returns cover message to be send after build has been completed.Integer
getBuildStartedCodeReviewValue(Run r)
Finds the code review vote for build started of the specified build.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.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.Integer
getBuildStartedVerifiedValue(Run r)
Finds the verified vote for build started of the specified build.protected Integer
getCodeReviewValue(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.Notify
getHighestNotificationLevel(BuildMemory.MemoryImprint memoryImprint, boolean onlyBuilt)
Returns the highest configured notification level.Integer
getMinimumCodeReviewValue(BuildMemory.MemoryImprint memoryImprint, boolean onlyBuilt)
Returns the minimum code review value for the build results in the memory.Integer
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.Notify
getNotificationLevel(GerritTrigger trigger)
Returns the notification level value for the given trigger.protected Integer
getVerifiedValue(Result res, GerritTrigger trigger)
Finds the verified value for the specified build result on the configured trigger.
-
-
-
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.
-
getBuildStartedVerifiedValue
public Integer getBuildStartedVerifiedValue(Run r)
Finds the verified vote for build started of the specified build. If there is aGerritTrigger
and 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
public Integer getBuildStartedCodeReviewValue(Run r)
Finds the code review vote for build started of the specified build. If there is aGerritTrigger
and 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
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 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.
-
-