@Extension(ordinal=10003.0)
public final class ToGerritRunListener
extends hudson.model.listeners.RunListener<hudson.model.Run>
Modifier and Type | Field and Description |
---|---|
static int |
ORDINAL
The ordering of this extension.
|
Constructor and Description |
---|
ToGerritRunListener() |
Modifier and Type | Method and Description |
---|---|
void |
allBuildsCompleted(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event,
GerritCause cause,
hudson.model.TaskListener listener)
Manages the end of a Gerrit Event.
|
protected void |
cleanUpGerritCauses(GerritCause firstFound,
hudson.model.Run build)
Workaround for builds that are triggered by the same Gerrit cause but multiple times in the same quiet period.
|
protected String |
getExpandedContent(hudson.FilePath path,
hudson.EnvVars envVars)
Returns the expanded file contents using the provided environment variables.
|
static ToGerritRunListener |
getInstance()
Returns the registered instance of this class from the list of all listeners.
|
protected hudson.FilePath[] |
getMatchingWorkspaceFiles(hudson.FilePath ws,
String filepath)
Searches the
workspace for files matching the filepath glob. |
boolean |
isBuilding(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Checks the memory if the event is building.
|
boolean |
isBuilding(hudson.model.Job project,
com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Checks the memory if the project is currently building the event.
|
boolean |
isProjectTriggeredAndIncomplete(hudson.model.Job p,
com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Checks whether a project has triggered for an event but hasn't yet finished building.
|
boolean |
isTriggered(hudson.model.Job project,
com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Checks the memory if the project is triggered by the event.
|
void |
onCompleted(hudson.model.Run r,
hudson.model.TaskListener listener) |
void |
onRetriggered(hudson.model.Job project,
com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event,
List<hudson.model.Run> otherBuilds)
Called just before a build is scheduled by the user to retrigger.
|
void |
onStarted(hudson.model.Run r,
hudson.model.TaskListener listener) |
void |
onTriggered(hudson.model.Job project,
com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Called just before a build is scheduled by the trigger.
|
BuildMemoryReport |
report()
Creates a snapshot report of the current contents of the
BuildMemory . |
void |
setBuildCustomUrl(hudson.model.Run r,
String customUrl)
Records a custom URL for the given build.
|
void |
setBuildUnsuccessfulMessage(hudson.model.Run r,
String unsuccessfulMessage)
Records the unsuccessful message for the given build.
|
void |
setQueueCancelled(hudson.model.Job project,
com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Sets the memory of the project to buildCompleted.
|
protected void |
setThisBuild(hudson.model.Run r)
Updates all
GerritCause s
TriggerContext.thisBuild
in the build. |
protected void |
updateTriggerContexts(hudson.model.Run r)
Updates the
TriggerContext s for all the
GerritCause s in the build. |
public static final int ORDINAL
@CheckForNull public static ToGerritRunListener getInstance()
public void setBuildCustomUrl(@Nonnull hudson.model.Run r, @Nonnull String customUrl)
r
- the build.customUrl
- the URL.public void setBuildUnsuccessfulMessage(@Nonnull hudson.model.Run r, @Nonnull String unsuccessfulMessage)
r
- the build that caused the failure.unsuccessfulMessage
- the unsuccessful messagepublic void onCompleted(@Nonnull hudson.model.Run r, @Nonnull hudson.model.TaskListener listener)
onCompleted
in class hudson.model.listeners.RunListener<hudson.model.Run>
@Nonnull public BuildMemoryReport report()
BuildMemory
.Diagnostics
public void allBuildsCompleted(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, GerritCause cause, hudson.model.TaskListener listener)
event
- the Gerrit Event which may need to be completed.cause
- the Gerrit Cause which triggered the build initially.listener
- the Jenkins listener.public boolean isProjectTriggeredAndIncomplete(hudson.model.Job p, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
event
- the Gerrit Event which is being checked.p
- the Gerrit project being checked.public void onStarted(hudson.model.Run r, hudson.model.TaskListener listener)
onStarted
in class hudson.model.listeners.RunListener<hudson.model.Run>
protected void updateTriggerContexts(hudson.model.Run r)
TriggerContext
s for all the
GerritCause
s in the build.r
- the build.BuildMemory.updateTriggerContext(
com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritCause,
hudson.model.Run)
protected void setThisBuild(hudson.model.Run r)
GerritCause
s
TriggerContext.thisBuild
in the build.r
- the build to update.protected void cleanUpGerritCauses(GerritCause firstFound, hudson.model.Run build)
firstFound
- the cause first returned by Run.getCause(Class)
.build
- the build to clean up.public void onTriggered(hudson.model.Job project, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
project
- the project that will be built.event
- the event that caused the build to be scheduled.public void onRetriggered(hudson.model.Job project, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, List<hudson.model.Run> otherBuilds)
project
- the project.event
- the event.otherBuilds
- the list of other builds in the previous context.public boolean isBuilding(hudson.model.Job project, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
project
- the project.event
- the event.BuildMemory.isBuilding(GerritTriggeredEvent, hudson.model.Job)
public boolean isBuilding(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
event
- the event.BuildMemory.isBuilding(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent)
public boolean isTriggered(hudson.model.Job project, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
project
- the project.event
- the event.public void setQueueCancelled(hudson.model.Job project, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
project
- the projectevent
- the event@Nonnull protected hudson.FilePath[] getMatchingWorkspaceFiles(@Nullable hudson.FilePath ws, @Nonnull String filepath) throws IOException, InterruptedException
workspace
for files matching the filepath
glob.ws
- The workspacefilepath
- The filepath glob patternFilePath
s. Guaranteed to be non-null.IOException
- if an error occurs while reading the workspaceInterruptedException
- if an error occurs while reading the workspaceprotected String getExpandedContent(hudson.FilePath path, hudson.EnvVars envVars) throws IOException, InterruptedException
null
will be returned if the path does not exist.path
- The file path being read.envVars
- The environment variables to use during expansion.null
if it does not exist.IOException
- if an error occurs while reading the fileInterruptedException
- if an error occurs while checking the status of the fileCopyright © 2016–2017. All rights reserved.