public class GStatsPublisher extends Recorder
{
  @Override
  public boolean perform(final AbstractBuild<?, ?> build,
                         final Launcher launcher,
                         final BuildListener listener)
  {
    // do the stuff 

    build.getActions().add(new GStatsBuildAction(build, results));

    listener.getLogger().out.println("... OK");
  } 

  public Action getProjectAction(final AbstractProject<?, ?> project)
  {
    return new GStatsProjectAction(project);
  }

  @Extension
  public static final GStatsPublisherDescriptor DESCRIPTOR = 
      new GStatsPublisherDescriptor();
} 
    
There's more going on here than it might at first appear.

This is a publisher, it runs after the build has completed, so it needs to extend Recorder. Obviously. The extry point for Records is the perform method. BuildListener is, basically, a logger. Anything you write to it winds up on the page. Launcher is the kind of build environment - where the build ran, what commands it used, and so on. I've never had cause to really look at it. AbstractBuild? Wha? That's the build object - the bottom blob on the tree I showed you earlier.

Jenkins works really well, but underneath is a code base that grown in fits and starts over the course of the past 6 or 7 years. Some of it is proper ugly.

The builders have completed. GStats does its thing, and then it wants to communicate those results back to us. It could just write a load of text to the listener and it would sit on the bottom on the console and we'd never look at it. If you want to do something more exciting - an icon or a graph or something, then you record the result by added a BuildAction to the build object. You also want to associate a project action with the project. You'll note again we're being passed in an Abstract project.

So, what is this AbstractProject/AbstractBuild business? When you create a project, you're offered a list that included FreeStyle, Maven, External Job, and so on. Those are concrete Project classes. Each concrete Project class has a corresponding concrete Build class. So, the FreeStyleProject class is paired with the FreeStyleBuild class. The AbstractProject and AbstractBuild classes are down the hierarchy a bit. Quite a way down ...