@Extension(ordinal=10003.0) public final class ToGerritRunListener extends RunListener<Run>
ExtensionPoint.LegacyInstancesAreScopedToHudson
Modifier and Type | Field and Description |
---|---|
static int |
ORDINAL
The ordering of this extension.
|
LISTENERS, targetType
Constructor and Description |
---|
ToGerritRunListener() |
Modifier and Type | Method and Description |
---|---|
void |
allBuildsCompleted(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event,
GerritCause cause,
TaskListener listener)
Manages the end of a Gerrit Event.
|
protected void |
cleanUpGerritCauses(GerritCause firstFound,
Run build)
Workaround for builds that are triggered by the same Gerrit cause but multiple times in the same quiet period.
|
protected String |
getExpandedContent(FilePath path,
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 FilePath[] |
getMatchingWorkspaceFiles(FilePath ws,
String filepath)
Searches the
workspace for files matching the filepath glob. |
List<Run> |
getRuns(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Get runs triggered for event.
|
boolean |
isBuilding(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Checks the memory if the event is building.
|
boolean |
isBuilding(Job project,
com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Checks the memory if the project is currently building the event.
|
boolean |
isProjectTriggeredAndIncomplete(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(Job project,
com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Checks the memory if the project is triggered by the event.
|
void |
notifyProjectRemoved(Job project)
Cleans the project from run listener related data structures.
|
void |
onCompleted(Run r,
TaskListener listener) |
void |
onRetriggered(Job project,
com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event,
List<Run> otherBuilds)
Called just before a build is scheduled by the user to retrigger.
|
void |
onStarted(Run r,
TaskListener listener) |
void |
onTriggered(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(Run r,
String customUrl)
Records a custom URL for the given build.
|
void |
setBuildUnsuccessfulMessage(Run r,
String unsuccessfulMessage)
Records the unsuccessful message for the given build.
|
void |
setQueueCancelled(Job project,
com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
Sets the memory of the project to buildCompleted.
|
protected void |
setThisBuild(Run r)
Updates all
GerritCause s
TriggerContext.thisBuild
in the build. |
protected void |
updateTriggerContexts(Run r)
Updates the
TriggerContext s for all the
GerritCause s in the build. |
all, fireCompleted, fireDeleted, fireFinalized, fireInitialize, fireStarted, onDeleted, onFinalized, onInitialize, register, setUpEnvironment, unregister
public static final int ORDINAL
@CheckForNull public static ToGerritRunListener getInstance()
public void setBuildCustomUrl(@Nonnull Run r, @Nonnull String customUrl)
r
- the build.customUrl
- the URL.public void setBuildUnsuccessfulMessage(@Nonnull Run r, @Nonnull String unsuccessfulMessage)
r
- the build that caused the failure.unsuccessfulMessage
- the unsuccessful messagepublic void onCompleted(@Nonnull Run r, @Nonnull TaskListener listener)
onCompleted
in class RunListener<Run>
@Nonnull public BuildMemoryReport report()
BuildMemory
.Diagnostics
public void allBuildsCompleted(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, GerritCause cause, 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(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(Run r, TaskListener listener)
onStarted
in class RunListener<Run>
@Nullable public List<Run> getRuns(com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
event
- the Gerrit Event which is being checked.protected void updateTriggerContexts(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(Run r)
GerritCause
s
TriggerContext.thisBuild
in the build.r
- the build to update.protected void cleanUpGerritCauses(GerritCause firstFound, Run build)
firstFound
- the cause first returned by Run.getCause(Class)
.build
- the build to clean up.public void onTriggered(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(Job project, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event, List<Run> otherBuilds)
project
- the project.event
- the event.otherBuilds
- the list of other builds in the previous context.public boolean isBuilding(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(Job project, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
project
- the project.event
- the event.public void setQueueCancelled(Job project, com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent event)
project
- the projectevent
- the eventpublic void notifyProjectRemoved(Job project)
project
- the project to be removed.@Nonnull protected FilePath[] getMatchingWorkspaceFiles(@Nullable 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(FilePath path, 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–2019. All rights reserved.