hudson.ivy
Class IvyReporter

java.lang.Object
  extended by hudson.ivy.IvyReporter
All Implemented Interfaces:
hudson.ExtensionPoint, hudson.model.Describable<IvyReporter>, java.io.Serializable

public abstract class IvyReporter
extends java.lang.Object
implements hudson.model.Describable<IvyReporter>, hudson.ExtensionPoint, java.io.Serializable

Listens to the build execution of IvyBuild, and normally records some information and exposes thoses in IvyBuild later.

IvyReporter is first instanciated on the master. Then during the build, it is serialized and sent over into the Ant process by serialization. Reporters will then receive event callbacks as Ant build events. Those event callbacks are the ones that take IvyBuildProxy.

Once the Ant build completes normally or abnormally, the reporters will be sent back to the master by serialization again, then have its end(IvyBuild, Launcher, BuildListener) method invoked. This is a good opportunity to perform the post-build action.

This is the IvyBuild equivalent of BuildStep. Instances of IvyReporters are persisted with IvyModule/IvyModuleSet, possibly with configuration specific to that job.

Callback Firing Sequence

The callback methods are invoked in the following order:

 SEQUENCE := preBuild MODULE* postBuild end
 MODULE   := enterModule leaveModule
 

When an error happens, the call sequence could be terminated at any point and no further callback methods may be invoked.

Action

IvyReporter can contribute Action to IvyBuild so that the report can be displayed in the web UI.

Such action can also implement AggregatableAction if it further wishes to contribute a separate action to IvyModuleSetBuild. This mechanism is usually used to provide aggregated report for all the module builds.

Author:
Kohsuke Kawaguchi
See Also:
IvyReporters, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Constructor Summary
IvyReporter()
           
 
Method Summary
 boolean end(IvyBuild build, hudson.Launcher launcher, hudson.model.BuildListener listener)
          Called after the Ant/Ivy execution finished and the result is determined.
 boolean enterModule(IvyBuildProxy build, org.apache.tools.ant.BuildEvent event, hudson.model.BuildListener listener)
          Called when the build enters a next IvyProject.
 hudson.model.Action getAggregatedProjectAction(IvyModuleSet project)
          Works like getProjectAction(IvyModule) but works at IvyModuleSet level.
 IvyReporterDescriptor getDescriptor()
           
 hudson.model.Action getProjectAction(IvyModule module)
          Equivalent of BuildStep.getProjectAction(AbstractProject) for IvyReporter.
 boolean leaveModule(IvyBuildProxy build, org.apache.tools.ant.BuildEvent event, hudson.model.BuildListener listener)
          Called when the build leaves the current IvyProject.
 boolean postBuild(IvyBuildProxy build, org.apache.tools.ant.BuildEvent event, hudson.model.BuildListener listener)
          Called after a build of one Ivy module is completed.
 boolean preBuild(IvyBuildProxy build, org.apache.tools.ant.BuildEvent event, hudson.model.BuildListener listener)
          Called before the actual ant execution begins.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IvyReporter

public IvyReporter()
Method Detail

preBuild

public boolean preBuild(IvyBuildProxy build,
                        org.apache.tools.ant.BuildEvent event,
                        hudson.model.BuildListener listener)
                 throws java.lang.InterruptedException,
                        java.io.IOException
Called before the actual ant execution begins.

Parameters:
moduleDescriptor - Represents the Ivy module to be executed.
Returns:
true if the build can continue, false if there was an error and the build needs to be aborted.
Throws:
java.lang.InterruptedException - If the build is interrupted by the user (in an attempt to abort the build.) Normally the IvyReporter implementations may simply forward the exception it got from its lower-level functions.
java.io.IOException - If the implementation wants to abort the processing when an IOException happens, it can simply propagate the exception to the caller. This will cause the build to fail, with the default error message. Implementations are encouraged to catch IOException on its own to provide a better error message, if it can do so, so that users have better understanding on why it failed.

enterModule

public boolean enterModule(IvyBuildProxy build,
                           org.apache.tools.ant.BuildEvent event,
                           hudson.model.BuildListener listener)
                    throws java.lang.InterruptedException,
                           java.io.IOException
Called when the build enters a next IvyProject.

When the current build is a multi-module reactor build, every time the build moves on to the next module, this method will be invoked.

Returns:
See preBuild(hudson.ivy.IvyBuildProxy, org.apache.tools.ant.BuildEvent, hudson.model.BuildListener)
Throws:
java.lang.InterruptedException - See preBuild(hudson.ivy.IvyBuildProxy, org.apache.tools.ant.BuildEvent, hudson.model.BuildListener)
java.io.IOException - See preBuild(hudson.ivy.IvyBuildProxy, org.apache.tools.ant.BuildEvent, hudson.model.BuildListener)

leaveModule

public boolean leaveModule(IvyBuildProxy build,
                           org.apache.tools.ant.BuildEvent event,
                           hudson.model.BuildListener listener)
                    throws java.lang.InterruptedException,
                           java.io.IOException
Called when the build leaves the current IvyProject.

Throws:
java.lang.InterruptedException
java.io.IOException
See Also:
enterModule(hudson.ivy.IvyBuildProxy, org.apache.tools.ant.BuildEvent, hudson.model.BuildListener)

postBuild

public boolean postBuild(IvyBuildProxy build,
                         org.apache.tools.ant.BuildEvent event,
                         hudson.model.BuildListener listener)
                  throws java.lang.InterruptedException,
                         java.io.IOException
Called after a build of one Ivy module is completed.

Note that at this point the build result is still not determined.

Returns:
See preBuild(hudson.ivy.IvyBuildProxy, org.apache.tools.ant.BuildEvent, hudson.model.BuildListener)
Throws:
java.lang.InterruptedException - See preBuild(hudson.ivy.IvyBuildProxy, org.apache.tools.ant.BuildEvent, hudson.model.BuildListener)
java.io.IOException - See preBuild(hudson.ivy.IvyBuildProxy, org.apache.tools.ant.BuildEvent, hudson.model.BuildListener)

end

public boolean end(IvyBuild build,
                   hudson.Launcher launcher,
                   hudson.model.BuildListener listener)
            throws java.lang.InterruptedException,
                   java.io.IOException
Called after the Ant/Ivy execution finished and the result is determined.

This method fires after #postBuild(IvyBuildProxy, ModuleDescriptor, BuildListener). Works like BuildStepCompatibilityLayer.perform(Build, Launcher, BuildListener).

Throws:
java.lang.InterruptedException
java.io.IOException

getProjectAction

public hudson.model.Action getProjectAction(IvyModule module)
Equivalent of BuildStep.getProjectAction(AbstractProject) for IvyReporter.

Registers a transient action to IvyModule when it's rendered. This is useful if you'd like to display an action at the module level.

Since this contributes a transient action, the returned Action will not be serialized.

For this method to be invoked, your IvyReporter has to invoke IvyBuildProxy.registerAsProjectAction(IvyReporter) during the build.

Returns:
null not to contribute an action, which is the default.

getAggregatedProjectAction

public hudson.model.Action getAggregatedProjectAction(IvyModuleSet project)
Works like getProjectAction(IvyModule) but works at IvyModuleSet level.

For this method to be invoked, your IvyReporter has to invoke IvyBuildProxy.registerAsAggregatedProjectAction(IvyReporter) during the build.

Returns:
null not to contribute an action, which is the default.

getDescriptor

public IvyReporterDescriptor getDescriptor()
Specified by:
getDescriptor in interface hudson.model.Describable<IvyReporter>


Copyright © 2010. All Rights Reserved.