Class GerritTrigger
- java.lang.Object
-
- hudson.triggers.Trigger<Job>
-
- com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<Trigger<?>>
public class GerritTrigger extends Trigger<Job>
Triggers a build based on Gerrit events.- Author:
- Robert Sandell <robert.sandell@sonyericsson.com>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class hudson.triggers.Trigger
Trigger.Cron
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description GerritTrigger(List<GerritProject> gerritProjects)
Default DataBound Constructor.GerritTrigger(List<GerritProject> gerritProjects, SkipVote skipVote, Integer gerritBuildStartedVerifiedValue, Integer gerritBuildStartedCodeReviewValue, Integer gerritBuildSuccessfulVerifiedValue, Integer gerritBuildSuccessfulCodeReviewValue, Integer gerritBuildFailedVerifiedValue, Integer gerritBuildFailedCodeReviewValue, Integer gerritBuildUnstableVerifiedValue, Integer gerritBuildUnstableCodeReviewValue, Integer gerritBuildNotBuiltVerifiedValue, Integer gerritBuildNotBuiltCodeReviewValue, boolean silentMode, boolean silentStartMode, boolean escapeQuotes, boolean noNameAndEmailParameters, boolean readableMessage, String dependencyJobsNames, String buildStartMessage, String buildSuccessfulMessage, String buildUnstableMessage, String buildFailureMessage, String buildNotBuiltMessage, String buildUnsuccessfulFilepath, String customUrl, String serverName, String gerritSlaveId, List<PluginGerritEvent> triggerOnEvents, boolean dynamicTriggerConfiguration, String triggerConfigURL, String notificationLevel)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected boolean
abortBecauseOfTopic(com.sonymobile.tools.gerrit.gerritevents.dto.events.ChangeBasedEvent event, BuildCancellationPolicy policy, com.sonymobile.tools.gerrit.gerritevents.dto.events.ChangeBasedEvent runningChange)
Checks that execution must be aborted because of topic.void
cancelTimer()
Cancels the timerTask, if it exists.protected ParametersAction
createParameters(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Job project)
Deprecated.ListBoxModel
doFillVerdictCategoryItems()
Fills the verdict category drop-down list for the comment-added events.boolean
equals(Object obj)
List<GerritSlave>
gerritSlavesToWaitFor(String gerritServerName)
Convenience method to get the list of GerritSlave to which replication should be done before letting the build execute.String
getBuildAbortedMessage()
The message to show users when a build is aborted, if custom messages are enabled.BuildCancellationPolicy
getBuildCancellationPolicy()
String
getBuildFailureMessage()
The message to show users when a build finishes, if custom messages are enabled.String
getBuildNotBuiltMessage()
The message to show users when all builds are not built, if custom messages are enabled.int
getBuildScheduleDelay()
getBuildScheduleDelay method will return configured buildScheduledelay value.String
getBuildStartMessage()
The message to show users when a build starts, if custom messages are enabled.String
getBuildSuccessfulMessage()
The message to show users when a build succeeds, if custom messages are enabled.String
getBuildUnstableMessage()
The message to show users when a build is unstable, if custom messages are enabled.String
getBuildUnsuccessfulFilepath()
The path to a file that contains the unsuccessful Gerrit comment message.GerritTriggerParameters.ParameterMode
getChangeSubjectParameterMode()
What mode the change subject parameterGerritTriggerParameters.GERRIT_CHANGE_SUBJECT
should be used when adding it.GerritTriggerParameters.ParameterMode
getCommentTextParameterMode()
What mode the comment text parameterGerritTriggerParameters.GERRIT_EVENT_COMMENT_TEXT
should be used when adding it.GerritTriggerParameters.ParameterMode
getCommitMessageParameterMode()
What mode the commit message parameterGerritTriggerParameters.GERRIT_CHANGE_COMMIT_MESSAGE
should be used when adding it.String
getCustomUrl()
URL to send in comment to Gerrit.String
getDependencyJobsNames()
The list of dependency jobs, ie jobs on which this job depends.TriggerDescriptor
getDescriptor()
List<GerritProject>
getDynamicGerritProjects()
The list of dynamically configured triggering rules.Integer
getGerritBuildAbortedCodeReviewValue()
Job specific Gerrit code review vote when a build is aborted, null means that the global value should be used.Integer
getGerritBuildAbortedVerifiedValue()
Job specific Gerrit verified vote when a build is aborted, null means that the global value should be used.Integer
getGerritBuildFailedCodeReviewValue()
Job specific Gerrit code review vote when a build is failed, null means that the global value should be used.Integer
getGerritBuildFailedVerifiedValue()
Job specific Gerrit verified vote when a build is failed, null means that the global value should be used.Integer
getGerritBuildNotBuiltCodeReviewValue()
Job specific Gerrit code review vote when a build is not built, null means that the global value should be used.Integer
getGerritBuildNotBuiltVerifiedValue()
Job specific Gerrit verified vote when a build is not built, null means that the global value should be used.Integer
getGerritBuildStartedCodeReviewValue()
Job specific Gerrit code review vote when a build is started, null means that the global value should be used.Integer
getGerritBuildStartedVerifiedValue()
Job specific Gerrit verified vote when a build is started, null means that the global value should be used.Integer
getGerritBuildSuccessfulCodeReviewValue()
Job specific Gerrit code review vote when a build is successful, null means that the global value should be used.Integer
getGerritBuildSuccessfulVerifiedValue()
Job specific Gerrit verified vote when a build is successful, null means that the global value should be used.Integer
getGerritBuildUnstableCodeReviewValue()
Job specific Gerrit code review vote when a build is unstable, null means that the global value should be used.Integer
getGerritBuildUnstableVerifiedValue()
Job specific Gerrit verified vote when a build is unstable, null means that the global value should be used.List<GerritProject>
getGerritProjects()
The list of GerritProject triggering rules.String
getGerritSlaveId()
The selected slave associated to this job, if enabled in server configs.GerritTriggerParameters.ParameterMode
getNameAndEmailParameterMode()
The parameter mode for the compound "name and email" parameters.String
getNotificationLevel()
Whom to notify.List<Action>
getProjectActions()
String
getServerName()
Returns name of server.SkipVote
getSkipVote()
The skip vote selection.TopicAssociation
getTopicAssociation()
Returns the assigned TopicAssociation object.static GerritTrigger
getTrigger(Job project)
Finds the GerritTrigger in a project.String
getTriggerConfigURL()
The URL where the trigger configuration should be fetched from.List<PluginGerritEvent>
getTriggerOnEvents()
Getter for the triggerOnEvents list.int
hashCode()
boolean
isBuildCurrentPatchesOnly()
The build cancellation policy regarding building current patch sets only.boolean
isDynamicTriggerConfiguration()
If trigger configuration should be fetched from a URL or not.boolean
isEnableTopicAssociation()
Deprecated.boolean
isEscapeQuotes()
if escapeQuotes is on or off.boolean
isFileTriggerEnabled()
Convenience method for finding it out if file triggering is enabled in the Gerrit version.boolean
isInteresting(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Should we trigger on this event?boolean
isNoNameAndEmailParameters()
Deprecated.replaced withgetNameAndEmailParameterMode()
boolean
isOnlyAbortRunningBuild(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Checks based on the current event if the job should just be aborted, or even a new job should be triggered.boolean
isReadableMessage()
Deprecated.replaced withgetCommitMessageParameterMode()
boolean
isSilentMode()
If silent mode is on or off.boolean
isSilentStartMode()
If silent start mode is on or off.boolean
isTriggerOnDraftPublishedEnabled()
Convenience method for finding it out if triggering on draft published is enabled in the Gerrit version.void
notifyBuildEnded(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Used to inform the server that the builds for a job have ended.Object
readResolve()
Converts old trigger configs when only patchset created was available as event and when jobs were not associated to Gerrit servers.void
retriggerAllBuilds(TriggerContext context)
Retriggers all builds in the given context.void
retriggerThisBuild(TriggerContext context)
Re-triggers the build inTriggerContext.getThisBuild()
for the context's event.protected void
schedule(GerritCause cause, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Deprecated.protected void
schedule(GerritCause cause, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Job project)
Deprecated.void
setBuildAbortedMessage(String buildAbortedMessage)
Message to write to Gerrit when a build is aborted.void
setBuildCancellationPolicy(BuildCancellationPolicy buildCancellationPolicy)
The build cancellation policy regarding building current patch sets only.void
setBuildFailureMessage(String buildFailureMessage)
Message to write to Gerrit when a build fails.void
setBuildNotBuiltMessage(String buildNotBuiltMessage)
Message to write to Gerrit when all builds are not built.void
setBuildStartMessage(String buildStartMessage)
Message to write to Gerrit when a build begins.void
setBuildSuccessfulMessage(String buildSuccessfulMessage)
Message to write to Gerrit when a build succeeds.void
setBuildUnstableMessage(String buildUnstableMessage)
Message to write to Gerrit when a build is unstable.void
setBuildUnsuccessfulFilepath(String buildUnsuccessfulFilepath)
Sets the path to a file that contains the unsuccessful Gerrit comment message.void
setChangeSubjectParameterMode(GerritTriggerParameters.ParameterMode changeSubjectParameterMode)
What mode the change subject parameterGerritTriggerParameters.GERRIT_CHANGE_SUBJECT
should be used when adding it.void
setCommentTextParameterMode(GerritTriggerParameters.ParameterMode commentTextParameterMode)
What mode the comment text parameterGerritTriggerParameters.GERRIT_EVENT_COMMENT_TEXT
should be used when adding it.void
setCommitMessageParameterMode(GerritTriggerParameters.ParameterMode commitMessageParameterMode)
What mode the commit message parameterGerritTriggerParameters.GERRIT_CHANGE_COMMIT_MESSAGE
should be used when adding it.void
setCustomUrl(String customUrl)
Custom URL to send to Gerrit instead of build URL.void
setDependencyJobsNames(String dependencyJobsNames)
The list of jobs on which this job depends.void
setDynamicTriggerConfiguration(boolean dynamicTriggerConfiguration)
Set if dynamic trigger configuration should be enabled or not.void
setEnableTopicAssociation(boolean enable)
Deprecated.void
setEscapeQuotes(boolean escapeQuotes)
Sets escapeQuotes to on or off.void
setGerritBuildAbortedCodeReviewValue(Integer gerritBuildAbortedCodeReviewValue)
Job specific Gerrit code review vote when a build is aborted, providing null means that the global value should be used.void
setGerritBuildAbortedVerifiedValue(Integer gerritBuildAbortedVerifiedValue)
Job specific Gerrit verified vote when a build is aborted, providing null means that the global value should be used.void
setGerritBuildFailedCodeReviewValue(Integer gerritBuildFailedCodeReviewValue)
Job specific Gerrit code review vote when a build is failed, providing null means that the global value should be used.void
setGerritBuildFailedVerifiedValue(Integer gerritBuildFailedVerifiedValue)
Job specific Gerrit verified vote when a build is failed, providing null means that the global value should be used.void
setGerritBuildNotBuiltCodeReviewValue(Integer gerritBuildNotBuiltCodeReviewValue)
Job specific Gerrit code review vote when a build is not built, providing null means that the global value should be used.void
setGerritBuildNotBuiltVerifiedValue(Integer gerritBuildNotBuiltVerifiedValue)
Job specific Gerrit verified vote when a build is not built, providing null means that the global value should be used.void
setGerritBuildStartedCodeReviewValue(Integer gerritBuildStartedCodeReviewValue)
Job specific Gerrit code review vote when a build is started, providing null means that the global value should be used.void
setGerritBuildStartedVerifiedValue(Integer gerritBuildStartedVerifiedValue)
Job specific Gerrit verified vote when a build is started, providing null means that the global value should be used.void
setGerritBuildSuccessfulCodeReviewValue(Integer gerritBuildSuccessfulCodeReviewValue)
Job specific Gerrit code review vote when a build is successful, providing null means that the global value should be used.void
setGerritBuildSuccessfulVerifiedValue(Integer gerritBuildSuccessfulVerifiedValue)
Job specific Gerrit verified vote when a build is successful, providing null means that the global value should be used.void
setGerritBuildUnstableCodeReviewValue(Integer gerritBuildUnstableCodeReviewValue)
Job specific Gerrit code review vote when a build is unstable, providing null means that the global value should be used.void
setGerritBuildUnstableVerifiedValue(Integer gerritBuildUnstableVerifiedValue)
Job specific Gerrit verified vote when a build is unstable, providing null means that the global value should be used.void
setGerritProjects(List<GerritProject> gerritProjects)
The list of GerritProject triggering rules.void
setGerritSlaveId(String gerritSlaveId)
The selected slave associated to this job, if enabled in server configs.void
setNameAndEmailParameterMode(GerritTriggerParameters.ParameterMode nameAndEmailParameterMode)
The parameter mode for the compound "name and email" parameters.void
setNoNameAndEmailParameters(boolean noNameAndEmailParameters)
Deprecated.void
setNotificationLevel(String notificationLevel)
Whom to notify.void
setReadableMessage(boolean readableMessage)
Deprecated.void
setServerName(String name)
Set the selected server.void
setSilentMode(boolean silentMode)
Sets silent mode to on or off.void
setSilentStartMode(boolean silentStartMode)
Sets silent start mode to on or off.void
setSkipVote(SkipVote skipVote)
The skip vote selection.void
setTopicAssociation(TopicAssociation topicAssociation)
DataBoundSetter for TopicAssociation.void
setTriggerConfigURL(String triggerConfigURL)
Set the URL where the trigger configuration should be fetched from.void
setTriggerOnEvents(List<PluginGerritEvent> triggerOnEvents)
The list of event types to trigger on.void
start(Job project, boolean newInstance)
void
stop()
void
updateTriggerConfigURL()
This method is called by the timer thread at regular intervals.void
waitForProjectListToBeReady()
Wait for the project list to be ready.-
Methods inherited from class hudson.triggers.Trigger
all, checkTriggers, for_, getProjectAction, getSpec, run, toString
-
-
-
-
Constructor Detail
-
GerritTrigger
@DataBoundConstructor public GerritTrigger(List<GerritProject> gerritProjects)
Default DataBound Constructor.- Parameters:
gerritProjects
- the set of triggering rules.
-
GerritTrigger
@Deprecated public GerritTrigger(List<GerritProject> gerritProjects, SkipVote skipVote, Integer gerritBuildStartedVerifiedValue, Integer gerritBuildStartedCodeReviewValue, Integer gerritBuildSuccessfulVerifiedValue, Integer gerritBuildSuccessfulCodeReviewValue, Integer gerritBuildFailedVerifiedValue, Integer gerritBuildFailedCodeReviewValue, Integer gerritBuildUnstableVerifiedValue, Integer gerritBuildUnstableCodeReviewValue, Integer gerritBuildNotBuiltVerifiedValue, Integer gerritBuildNotBuiltCodeReviewValue, boolean silentMode, boolean silentStartMode, boolean escapeQuotes, boolean noNameAndEmailParameters, boolean readableMessage, String dependencyJobsNames, String buildStartMessage, String buildSuccessfulMessage, String buildUnstableMessage, String buildFailureMessage, String buildNotBuiltMessage, String buildUnsuccessfulFilepath, String customUrl, String serverName, String gerritSlaveId, List<PluginGerritEvent> triggerOnEvents, boolean dynamicTriggerConfiguration, String triggerConfigURL, String notificationLevel)
Deprecated.Old DataBound Constructor. Replaced withGerritTrigger(List)
andDataBoundSetter
s.- Parameters:
gerritProjects
- the set of triggering rules.skipVote
- what votes if any should be skipped in the final verified/code review calculation.gerritBuildStartedVerifiedValue
- Job specific Gerrit verified vote when a build is started, null means that the global value should be used.gerritBuildStartedCodeReviewValue
- Job specific Gerrit code review vote when a build is started, null means that the global value should be used.gerritBuildSuccessfulVerifiedValue
- Job specific Gerrit verified vote when a build is successful, null means that the global value should be used.gerritBuildSuccessfulCodeReviewValue
- Job specific Gerrit code review vote when a build is successful, null means that the global value should be used.gerritBuildFailedVerifiedValue
- Job specific Gerrit verified vote when a build is failed, null means that the global value should be used.gerritBuildFailedCodeReviewValue
- Job specific Gerrit code review vote when a build is failed, null means that the global value should be used.gerritBuildUnstableVerifiedValue
- Job specific Gerrit verified vote when a build is unstable, null means that the global value should be used.gerritBuildUnstableCodeReviewValue
- Job specific Gerrit code review vote when a build is unstable, null means that the global value should be used.gerritBuildNotBuiltVerifiedValue
- Job specific Gerrit verified vote when a build is not built, null means that the global value should be used.gerritBuildNotBuiltCodeReviewValue
- Job specific Gerrit code review vote when a build is not built, null means that the global value should be used.silentMode
- Silent Mode on or off.silentStartMode
- Silent Start Mode on or off.escapeQuotes
- EscapeQuotes on or off.noNameAndEmailParameters
- Whether to create parameters containing name and emailreadableMessage
- Human readable message or not.dependencyJobsNames
- The list of jobs on which this job dependsbuildStartMessage
- Message to write to Gerrit when a build beginsbuildSuccessfulMessage
- Message to write to Gerrit when a build succeedsbuildUnstableMessage
- Message to write to Gerrit when a build is unstablebuildFailureMessage
- Message to write to Gerrit when a build failsbuildNotBuiltMessage
- Message to write to Gerrit when all builds are not builtbuildUnsuccessfulFilepath
- Filename to retrieve Gerrit comment message from, in the case of an unsuccessful build.customUrl
- Custom URL to send to Gerrit instead of build URLserverName
- The selected servergerritSlaveId
- The selected slave associated to this job, if enabled in server configstriggerOnEvents
- The list of event types to trigger on.dynamicTriggerConfiguration
- Dynamic trigger configuration on or offtriggerConfigURL
- Where to fetch the configuration file fromnotificationLevel
- Whom to notify.
-
-
Method Detail
-
getNameAndEmailParameterMode
@NonNull public GerritTriggerParameters.ParameterMode getNameAndEmailParameterMode()
The parameter mode for the compound "name and email" parameters. ReplacesisNoNameAndEmailParameters()
.
-
setNameAndEmailParameterMode
@DataBoundSetter public void setNameAndEmailParameterMode(@NonNull GerritTriggerParameters.ParameterMode nameAndEmailParameterMode)
The parameter mode for the compound "name and email" parameters. ReplacesisNoNameAndEmailParameters()
.- Parameters:
nameAndEmailParameterMode
- the mode- See Also:
GerritTriggerParameters.GERRIT_CHANGE_ABANDONER
,GerritTriggerParameters.GERRIT_CHANGE_OWNER
,GerritTriggerParameters.GERRIT_CHANGE_RESTORER
,GerritTriggerParameters.GERRIT_EVENT_ACCOUNT
,GerritTriggerParameters.GERRIT_SUBMITTER
-
getCommitMessageParameterMode
@NonNull public GerritTriggerParameters.ParameterMode getCommitMessageParameterMode()
What mode the commit message parameterGerritTriggerParameters.GERRIT_CHANGE_COMMIT_MESSAGE
should be used when adding it.- Returns:
- the mode
-
setCommitMessageParameterMode
@DataBoundSetter public void setCommitMessageParameterMode(@NonNull GerritTriggerParameters.ParameterMode commitMessageParameterMode)
What mode the commit message parameterGerritTriggerParameters.GERRIT_CHANGE_COMMIT_MESSAGE
should be used when adding it.- Parameters:
commitMessageParameterMode
- the mode
-
getChangeSubjectParameterMode
@NonNull public GerritTriggerParameters.ParameterMode getChangeSubjectParameterMode()
What mode the change subject parameterGerritTriggerParameters.GERRIT_CHANGE_SUBJECT
should be used when adding it.- Returns:
- the mode
-
setChangeSubjectParameterMode
@DataBoundSetter public void setChangeSubjectParameterMode(@NonNull GerritTriggerParameters.ParameterMode changeSubjectParameterMode)
What mode the change subject parameterGerritTriggerParameters.GERRIT_CHANGE_SUBJECT
should be used when adding it.- Parameters:
changeSubjectParameterMode
- the mode
-
getCommentTextParameterMode
@NonNull public GerritTriggerParameters.ParameterMode getCommentTextParameterMode()
What mode the comment text parameterGerritTriggerParameters.GERRIT_EVENT_COMMENT_TEXT
should be used when adding it.- Returns:
- the mode
-
setCommentTextParameterMode
@DataBoundSetter public void setCommentTextParameterMode(@NonNull GerritTriggerParameters.ParameterMode commentTextParameterMode)
What mode the comment text parameterGerritTriggerParameters.GERRIT_EVENT_COMMENT_TEXT
should be used when adding it.- Parameters:
commentTextParameterMode
- the mode
-
setSkipVote
@DataBoundSetter public void setSkipVote(SkipVote skipVote)
The skip vote selection. "Skipping" the vote means that if more than one build of this job is triggered by a Gerrit event the outcome of this build won't be counted when the final vote is sent to Gerrit.- Parameters:
skipVote
- what votes if any should be skipped in the final
-
getServerName
public String getServerName()
Returns name of server.- Returns:
- the server name
-
setServerName
@DataBoundSetter public void setServerName(String name)
Set the selected server.- Parameters:
name
- the name of the newly selected server.
-
getGerritSlaveId
public String getGerritSlaveId()
The selected slave associated to this job, if enabled in server configs.- Returns:
- the id of the gerrit slave
- See Also:
GerritSlave
-
setGerritSlaveId
@DataBoundSetter public void setGerritSlaveId(String gerritSlaveId)
The selected slave associated to this job, if enabled in server configs.- Parameters:
gerritSlaveId
- the id of the gerrit slave- See Also:
GerritSlave
-
getTrigger
public static GerritTrigger getTrigger(@Nullable Job project)
Finds the GerritTrigger in a project.- Parameters:
project
- the project.- Returns:
- the trigger if there is one, null otherwise.
-
cancelTimer
public void cancelTimer()
Cancels the timerTask, if it exists.
-
schedule
@Deprecated protected void schedule(GerritCause cause, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Deprecated.Schedules a build with parameters from the event. WithTrigger.job
as the project to build.- Parameters:
cause
- the cause of the build.event
- the event.
-
schedule
@Deprecated protected void schedule(GerritCause cause, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Job project)
Deprecated.Schedules a build with parameters from the event.- Parameters:
cause
- the cause of the build.event
- the event.project
- the project to build.
-
createParameters
@Deprecated protected ParametersAction createParameters(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, Job project)
Deprecated.Creates a ParameterAction and fills it with the project's default parameters + the Standard Gerrit parameters.- Parameters:
event
- the event.project
- the project.- Returns:
- the ParameterAction.
-
doFillVerdictCategoryItems
public ListBoxModel doFillVerdictCategoryItems()
Fills the verdict category drop-down list for the comment-added events.- Returns:
- a ListBoxModel for the drop-down list.
-
notifyBuildEnded
public void notifyBuildEnded(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Used to inform the server that the builds for a job have ended. This allows us to clean up our list of what jobs we're running.- Parameters:
event
- the event.
-
getBuildScheduleDelay
public int getBuildScheduleDelay()
getBuildScheduleDelay method will return configured buildScheduledelay value. If the value is missing or invalid it the method will return default schedule delay orGerritDefaultValues.DEFAULT_BUILD_SCHEDULE_DELAY
.- Returns:
- buildScheduleDelay.
-
retriggerThisBuild
public void retriggerThisBuild(TriggerContext context)
Re-triggers the build inTriggerContext.getThisBuild()
for the context's event. Will not do anyisInteresting(GerritTriggeredEvent)
checks. If more than one build was triggered by the event the results from those builds will be counted again, but they won't be re-triggered. If any builds for the event are still running, this new scheduled build will replace its predesessor. If the project is currently building the event, no scheduling will be done.- Parameters:
context
- the previous context.
-
retriggerAllBuilds
public void retriggerAllBuilds(TriggerContext context)
Retriggers all builds in the given context. The builds will only be triggered if no builds for the event are building.- Parameters:
context
- the context to rebuild.- See Also:
ToGerritRunListener.isBuilding(GerritTriggeredEvent)
-
isOnlyAbortRunningBuild
public boolean isOnlyAbortRunningBuild(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Checks based on the current event if the job should just be aborted, or even a new job should be triggered.- Parameters:
event
- The ChangeBasedEvent.- Returns:
- true if the job should only be aborted without triggering a new one, otherwise false.
-
isInteresting
public boolean isInteresting(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Should we trigger on this event?- Parameters:
event
- the event- Returns:
- true if we should.
-
getGerritProjects
public List<GerritProject> getGerritProjects()
The list of GerritProject triggering rules.- Returns:
- the rule-set.
-
getDynamicGerritProjects
public List<GerritProject> getDynamicGerritProjects()
The list of dynamically configured triggering rules.- Returns:
- the rule-set.
-
setGerritProjects
public void setGerritProjects(List<GerritProject> gerritProjects)
The list of GerritProject triggering rules.- Parameters:
gerritProjects
- the rule-set
-
getGerritBuildFailedCodeReviewValue
public Integer getGerritBuildFailedCodeReviewValue()
Job specific Gerrit code review vote when a build is failed, null means that the global value should be used.- Returns:
- the vote value.
-
setGerritBuildFailedCodeReviewValue
@DataBoundSetter public void setGerritBuildFailedCodeReviewValue(Integer gerritBuildFailedCodeReviewValue)
Job specific Gerrit code review vote when a build is failed, providing null means that the global value should be used.- Parameters:
gerritBuildFailedCodeReviewValue
- the vote value.
-
getGerritBuildFailedVerifiedValue
public Integer getGerritBuildFailedVerifiedValue()
Job specific Gerrit verified vote when a build is failed, null means that the global value should be used.- Returns:
- the vote value.
-
setGerritBuildFailedVerifiedValue
@DataBoundSetter public void setGerritBuildFailedVerifiedValue(Integer gerritBuildFailedVerifiedValue)
Job specific Gerrit verified vote when a build is failed, providing null means that the global value should be used.- Parameters:
gerritBuildFailedVerifiedValue
- the vote value.
-
getGerritBuildStartedCodeReviewValue
public Integer getGerritBuildStartedCodeReviewValue()
Job specific Gerrit code review vote when a build is started, null means that the global value should be used.- Returns:
- the vote value.
-
setGerritBuildStartedCodeReviewValue
@DataBoundSetter public void setGerritBuildStartedCodeReviewValue(Integer gerritBuildStartedCodeReviewValue)
Job specific Gerrit code review vote when a build is started, providing null means that the global value should be used.- Parameters:
gerritBuildStartedCodeReviewValue
- the vote value.
-
getGerritBuildStartedVerifiedValue
public Integer getGerritBuildStartedVerifiedValue()
Job specific Gerrit verified vote when a build is started, null means that the global value should be used.- Returns:
- the vote value.
-
setGerritBuildStartedVerifiedValue
@DataBoundSetter public void setGerritBuildStartedVerifiedValue(Integer gerritBuildStartedVerifiedValue)
Job specific Gerrit verified vote when a build is started, providing null means that the global value should be used.- Parameters:
gerritBuildStartedVerifiedValue
- the vote value.
-
getGerritBuildSuccessfulCodeReviewValue
public Integer getGerritBuildSuccessfulCodeReviewValue()
Job specific Gerrit code review vote when a build is successful, null means that the global value should be used.- Returns:
- the vote value.
-
setGerritBuildSuccessfulCodeReviewValue
@DataBoundSetter public void setGerritBuildSuccessfulCodeReviewValue(Integer gerritBuildSuccessfulCodeReviewValue)
Job specific Gerrit code review vote when a build is successful, providing null means that the global value should be used.- Parameters:
gerritBuildSuccessfulCodeReviewValue
- the vote value.
-
getGerritBuildSuccessfulVerifiedValue
public Integer getGerritBuildSuccessfulVerifiedValue()
Job specific Gerrit verified vote when a build is successful, null means that the global value should be used.- Returns:
- the vote value.
-
setGerritBuildSuccessfulVerifiedValue
@DataBoundSetter public void setGerritBuildSuccessfulVerifiedValue(Integer gerritBuildSuccessfulVerifiedValue)
Job specific Gerrit verified vote when a build is successful, providing null means that the global value should be used.- Parameters:
gerritBuildSuccessfulVerifiedValue
- the vote value.
-
getGerritBuildUnstableCodeReviewValue
public Integer getGerritBuildUnstableCodeReviewValue()
Job specific Gerrit code review vote when a build is unstable, null means that the global value should be used.- Returns:
- the vote value.
-
setGerritBuildUnstableCodeReviewValue
@DataBoundSetter public void setGerritBuildUnstableCodeReviewValue(Integer gerritBuildUnstableCodeReviewValue)
Job specific Gerrit code review vote when a build is unstable, providing null means that the global value should be used.- Parameters:
gerritBuildUnstableCodeReviewValue
- the vote value.
-
getGerritBuildUnstableVerifiedValue
public Integer getGerritBuildUnstableVerifiedValue()
Job specific Gerrit verified vote when a build is unstable, null means that the global value should be used.- Returns:
- the vote value.
-
setGerritBuildUnstableVerifiedValue
@DataBoundSetter public void setGerritBuildUnstableVerifiedValue(Integer gerritBuildUnstableVerifiedValue)
Job specific Gerrit verified vote when a build is unstable, providing null means that the global value should be used.- Parameters:
gerritBuildUnstableVerifiedValue
- the vote value.
-
getGerritBuildNotBuiltCodeReviewValue
public Integer getGerritBuildNotBuiltCodeReviewValue()
Job specific Gerrit code review vote when a build is not built, null means that the global value should be used.- Returns:
- the vote value.
-
setGerritBuildNotBuiltCodeReviewValue
@DataBoundSetter public void setGerritBuildNotBuiltCodeReviewValue(Integer gerritBuildNotBuiltCodeReviewValue)
Job specific Gerrit code review vote when a build is not built, providing null means that the global value should be used.- Parameters:
gerritBuildNotBuiltCodeReviewValue
- the vote value.
-
getGerritBuildNotBuiltVerifiedValue
public Integer getGerritBuildNotBuiltVerifiedValue()
Job specific Gerrit verified vote when a build is not built, null means that the global value should be used.- Returns:
- the vote value.
-
setGerritBuildNotBuiltVerifiedValue
@DataBoundSetter public void setGerritBuildNotBuiltVerifiedValue(Integer gerritBuildNotBuiltVerifiedValue)
Job specific Gerrit verified vote when a build is not built, providing null means that the global value should be used.- Parameters:
gerritBuildNotBuiltVerifiedValue
- the vote value.
-
getGerritBuildAbortedCodeReviewValue
public Integer getGerritBuildAbortedCodeReviewValue()
Job specific Gerrit code review vote when a build is aborted, null means that the global value should be used.- Returns:
- the vote value.
-
setGerritBuildAbortedCodeReviewValue
@DataBoundSetter public void setGerritBuildAbortedCodeReviewValue(Integer gerritBuildAbortedCodeReviewValue)
Job specific Gerrit code review vote when a build is aborted, providing null means that the global value should be used.- Parameters:
gerritBuildAbortedCodeReviewValue
- the vote value.
-
getGerritBuildAbortedVerifiedValue
public Integer getGerritBuildAbortedVerifiedValue()
Job specific Gerrit verified vote when a build is aborted, null means that the global value should be used.- Returns:
- the vote value.
-
setGerritBuildAbortedVerifiedValue
@DataBoundSetter public void setGerritBuildAbortedVerifiedValue(Integer gerritBuildAbortedVerifiedValue)
Job specific Gerrit verified vote when a build is aborted, providing null means that the global value should be used.- Parameters:
gerritBuildAbortedVerifiedValue
- the vote value.
-
setBuildUnsuccessfulFilepath
@DataBoundSetter public void setBuildUnsuccessfulFilepath(String buildUnsuccessfulFilepath)
Sets the path to a file that contains the unsuccessful Gerrit comment message. Filename to retrieve Gerrit comment message from, in the case of an unsuccessful build.- Parameters:
buildUnsuccessfulFilepath
- The unsuccessful message comment file path
-
getTriggerOnEvents
public List<PluginGerritEvent> getTriggerOnEvents()
Getter for the triggerOnEvents list.- Returns:
- the list.
-
setTriggerOnEvents
@DataBoundSetter public void setTriggerOnEvents(List<PluginGerritEvent> triggerOnEvents)
The list of event types to trigger on.- Parameters:
triggerOnEvents
- the list
-
isDynamicTriggerConfiguration
public boolean isDynamicTriggerConfiguration()
If trigger configuration should be fetched from a URL or not.- Returns:
- true if trigger configuration should be fetched from a URL.
-
setDynamicTriggerConfiguration
@DataBoundSetter public void setDynamicTriggerConfiguration(boolean dynamicTriggerConfiguration)
Set if dynamic trigger configuration should be enabled or not.- Parameters:
dynamicTriggerConfiguration
- true if dynamic trigger configuration should be enabled.
-
getTriggerConfigURL
public String getTriggerConfigURL()
The URL where the trigger configuration should be fetched from.- Returns:
- the URL, or null if this feature is not used.
-
setTriggerConfigURL
@DataBoundSetter public void setTriggerConfigURL(String triggerConfigURL)
Set the URL where the trigger configuration should be fetched from.- Parameters:
triggerConfigURL
- the URL where the trigger configuration should be fetched from.- See Also:
dynamicTriggerConfiguration
,dynamicGerritProjects
-
getDependencyJobsNames
public String getDependencyJobsNames()
The list of dependency jobs, ie jobs on which this job depends.- Returns:
- the string of jobs, or null if this feature is not used.
-
setDependencyJobsNames
@DataBoundSetter public void setDependencyJobsNames(String dependencyJobsNames)
The list of jobs on which this job depends.- Parameters:
dependencyJobsNames
- the string containing a comma-separated list of job names.
-
isSilentMode
public boolean isSilentMode()
If silent mode is on or off. When silent mode is on there will be no communication back to Gerrit, i.e. no build started/failed/successful approve messages etc. Default is false.- Returns:
- true if silent mode is on.
-
isSilentStartMode
public boolean isSilentStartMode()
If silent start mode is on or off. When silent start mode is on there will be no 'build started' message back to Gerrit. Default is false.- Returns:
- true if silent start mode is on.
-
getNotificationLevel
public String getNotificationLevel()
Whom to notify.- Returns:
- the notification level value
-
isEscapeQuotes
public boolean isEscapeQuotes()
if escapeQuotes is on or off. When escapeQuotes is on this plugin will escape quotes in Gerrit event parameter string Default is true- Returns:
- true if escapeQuotes is on.
-
setEscapeQuotes
@DataBoundSetter public void setEscapeQuotes(boolean escapeQuotes)
Sets escapeQuotes to on or off. When escapeQuotes is on plugin will escape quotes in Gerrit event parameter string. Default is false.- Parameters:
escapeQuotes
- is true if escapeQuotes should be on.
-
isNoNameAndEmailParameters
@Deprecated public boolean isNoNameAndEmailParameters()
Deprecated.replaced withgetNameAndEmailParameterMode()
If noNameAndEmailParameters is on or off. When this is set on this plugin will not create parameters which combine a name with an email (this applies change owner, restorer, etc). These parameters cause problems with some configurations.- Returns:
- true if noNameAndEmailParameters is on.
-
setNoNameAndEmailParameters
@Deprecated public void setNoNameAndEmailParameters(boolean noNameAndEmailParameters)
Deprecated.Sets noNameAndEmailParameters to on or off. When this is set on this plugin will not create parameters which combine a name with an email (this applies change owner, restorer, etc). These parameters cause problems with some configurations.- Parameters:
noNameAndEmailParameters
- is true if problematic parameters should be omitted.
-
isReadableMessage
@Deprecated public boolean isReadableMessage()
Deprecated.replaced withgetCommitMessageParameterMode()
If readableMessage is on or off. When this is set on this plugin will create parameters for multiline text, e.g. commit message, as human readable message. When this is set off, it will be encoded.- Returns:
- true if readableMessage is on.
-
setReadableMessage
@Deprecated public void setReadableMessage(boolean readableMessage)
Deprecated.Sets readableMessage to on or off. When this is set on this plugin will create parameters for multiline text, e.g. commit message, as human readable message. when this is set off, it will be encoded.- Parameters:
readableMessage
- is true if human readable message is set.
-
getBuildStartMessage
public String getBuildStartMessage()
The message to show users when a build starts, if custom messages are enabled.- Returns:
- The build start message
-
setBuildStartMessage
@DataBoundSetter public void setBuildStartMessage(String buildStartMessage)
Message to write to Gerrit when a build begins.- Parameters:
buildStartMessage
- The build start message
-
getBuildCancellationPolicy
public BuildCancellationPolicy getBuildCancellationPolicy()
- Returns:
- the buildCurrentPatchesOnly
-
isBuildCurrentPatchesOnly
public boolean isBuildCurrentPatchesOnly()
The build cancellation policy regarding building current patch sets only.- Returns:
- the policy
-
setBuildCancellationPolicy
@DataBoundSetter public void setBuildCancellationPolicy(BuildCancellationPolicy buildCancellationPolicy)
The build cancellation policy regarding building current patch sets only.- Parameters:
buildCancellationPolicy
- the policy
-
getBuildSuccessfulMessage
public String getBuildSuccessfulMessage()
The message to show users when a build succeeds, if custom messages are enabled.- Returns:
- The build successful message
-
setBuildSuccessfulMessage
@DataBoundSetter public void setBuildSuccessfulMessage(String buildSuccessfulMessage)
Message to write to Gerrit when a build succeeds.- Parameters:
buildSuccessfulMessage
- The build successful message
-
getBuildUnstableMessage
public String getBuildUnstableMessage()
The message to show users when a build is unstable, if custom messages are enabled.- Returns:
- The build unstable message
-
setBuildUnstableMessage
@DataBoundSetter public void setBuildUnstableMessage(String buildUnstableMessage)
Message to write to Gerrit when a build is unstable.- Parameters:
buildUnstableMessage
- The build unstable message
-
getBuildFailureMessage
public String getBuildFailureMessage()
The message to show users when a build finishes, if custom messages are enabled.- Returns:
- The build failure message
-
setBuildFailureMessage
@DataBoundSetter public void setBuildFailureMessage(String buildFailureMessage)
Message to write to Gerrit when a build fails.- Parameters:
buildFailureMessage
- The build failure message
-
getBuildNotBuiltMessage
public String getBuildNotBuiltMessage()
The message to show users when all builds are not built, if custom messages are enabled.- Returns:
- The build not built message
-
setBuildNotBuiltMessage
@DataBoundSetter public void setBuildNotBuiltMessage(String buildNotBuiltMessage)
Message to write to Gerrit when all builds are not built.- Parameters:
buildNotBuiltMessage
- The build not built message
-
getBuildAbortedMessage
public String getBuildAbortedMessage()
The message to show users when a build is aborted, if custom messages are enabled.- Returns:
- The build aborted message
-
setBuildAbortedMessage
@DataBoundSetter public void setBuildAbortedMessage(String buildAbortedMessage)
Message to write to Gerrit when a build is aborted.- Parameters:
buildAbortedMessage
- The build aborted message
-
getBuildUnsuccessfulFilepath
public String getBuildUnsuccessfulFilepath()
The path to a file that contains the unsuccessful Gerrit comment message.- Returns:
- The unsuccessful message comment file path
-
setSilentMode
@DataBoundSetter public void setSilentMode(boolean silentMode)
Sets silent mode to on or off. When silent mode is on there will be no communication back to Gerrit, i.e. no build started/failed/successful approve messages etc. Default is false.- Parameters:
silentMode
- true if silent mode should be on.
-
setEnableTopicAssociation
@Deprecated public void setEnableTopicAssociation(boolean enable)
Deprecated.Enable or disable Topic Association option. Replaced bysetTopicAssociation(TopicAssociation)
()- Parameters:
enable
- true or false.
-
isEnableTopicAssociation
@Deprecated public boolean isEnableTopicAssociation()
Deprecated.Check if topic association is enabled.- Returns:
- true if so.
-
setTopicAssociation
@DataBoundSetter public void setTopicAssociation(TopicAssociation topicAssociation)
DataBoundSetter for TopicAssociation. Used for jelly file.- Parameters:
topicAssociation
- the TopicAssociation object.
-
getTopicAssociation
@CheckForNull public TopicAssociation getTopicAssociation()
Returns the assigned TopicAssociation object. Used for jelly file.- Returns:
- TopicAssociation object
-
setSilentStartMode
@DataBoundSetter public void setSilentStartMode(boolean silentStartMode)
Sets silent start mode to on or off. When silent start mode is on there will be no 'silent start' message back to Gerrit. Default is false.- Parameters:
silentStartMode
- true if silent start mode should be on.
-
setNotificationLevel
@DataBoundSetter public void setNotificationLevel(String notificationLevel)
Whom to notify.- Parameters:
notificationLevel
- the notification level.
-
getCustomUrl
public String getCustomUrl()
URL to send in comment to Gerrit.- Returns:
- custom URL to post back to Gerrit
-
setCustomUrl
@DataBoundSetter public void setCustomUrl(String customUrl)
Custom URL to send to Gerrit instead of build URL.- Parameters:
customUrl
- URL to set
-
isFileTriggerEnabled
public boolean isFileTriggerEnabled()
Convenience method for finding it out if file triggering is enabled in the Gerrit version.- Returns:
- true if file triggering is enabled in the Gerrit version.
-
updateTriggerConfigURL
public void updateTriggerConfigURL()
This method is called by the timer thread at regular intervals. It fetches the URL, determines if the result is different than from the last fetch, and if so, replaces the current URL trigger configuration with the fetched one.
-
isTriggerOnDraftPublishedEnabled
public boolean isTriggerOnDraftPublishedEnabled()
Convenience method for finding it out if triggering on draft published is enabled in the Gerrit version.- Returns:
- true if triggering on draft published is enabled in the Gerrit version.
-
gerritSlavesToWaitFor
public List<GerritSlave> gerritSlavesToWaitFor(String gerritServerName)
Convenience method to get the list of GerritSlave to which replication should be done before letting the build execute.- Parameters:
gerritServerName
- The Gerrit server name- Returns:
- list of GerritSlave (can be empty but never null)
-
getProjectActions
public List<Action> getProjectActions()
- Overrides:
getProjectActions
in classTrigger<Job>
-
getSkipVote
public SkipVote getSkipVote()
The skip vote selection. "Skipping" the vote means that if more than one build of this job is triggered by a Gerrit event the outcome of this build won't be counted when the final vote is sent to Gerrit.- Returns:
- data structure for what build results to skip.
-
waitForProjectListToBeReady
public void waitForProjectListToBeReady() throws InterruptedException
Wait for the project list to be ready. This is here so that the EventListener can call it before it asks if an event is interesting (viaisInteresting(GerritTriggeredEvent)
).- Throws:
InterruptedException
- if the thread was interrupted while waiting.
-
readResolve
public Object readResolve() throws ObjectStreamException
Converts old trigger configs when only patchset created was available as event and when jobs were not associated to Gerrit servers.- Overrides:
readResolve
in classTrigger<Job>
- Returns:
- the resolved instance.
- Throws:
ObjectStreamException
- if something beneath goes wrong.
-
getDescriptor
public TriggerDescriptor getDescriptor()
- Specified by:
getDescriptor
in interfaceDescribable<Trigger<?>>
- Overrides:
getDescriptor
in classTrigger<Job>
-
abortBecauseOfTopic
protected boolean abortBecauseOfTopic(com.sonymobile.tools.gerrit.gerritevents.dto.events.ChangeBasedEvent event, BuildCancellationPolicy policy, com.sonymobile.tools.gerrit.gerritevents.dto.events.ChangeBasedEvent runningChange)
Checks that execution must be aborted because of topic.- Parameters:
event
- the event.policy
- the cancellation policy.runningChange
- the ongoing change.- Returns:
- true if so.
-
-