How to extend Jenkins job page with new links and icons

jenkins, jenkins-plugins

Solution

After a lot of trial and error I figured out the solution.

All in all you need two different things in your project:

1) A class that inherits from ProminentProjectAction:

import hudson.model.ProminentProjectAction;

public class MyProjectAction implements ProminentProjectAction {

    @Override
    public String getIconFileName() {
        // return the path to the icon file
        return "/images/jenkins.png";
    }

    @Override
    public String getDisplayName() {
        // return the label for your link
        return "MyActionLink";
    }

    @Override
    public String getUrlName() {
        // defines the suburl, which is appended to ...jenkins/job/jobname
        return "myactionpage";
    }
}

2) Even more important is that you add this action somehow to your project.

In my case I wanted to show the link if and only if the related build step of my plugin is configured for the actual project. So I took my Builder class and overwrote the getProjectActionsMethod.

public class MyBuilder extends Builder {

    ...

    @Override
    public Collection<? extends Action> getProjectActions(AbstractProject<?,?> project) {
        List<Action> actions = new ArrayList<>();
        actions.add(new MyProjectAction());

        return actions;
    }
}

Maybe this is not the perfect solution yet (because I'm still trying to figure out how all the artifacts are working together), but it might give people which want to implement the same a good starting point.

The page, which is loaded after clicking the link is defined as index.jelly file under source/main/resources and an underlying package with the name of the package of your Action class appended by its class name (e.g. src/main/resources/org/example/myplugin/MyProjectAction).

Problem

I'm developing my first Jenkins plugin and followed the tutorial at wiki.jenkins-ci.org. After adding a BuildStep and generating the results I now want to publish them to the user. I would like to do this via a new link entry on the job page and a corrsponding result view page. Unfortunatelly I do not find the right extension points for the navigation bar at the left side, the main navigation links in the center as well as the new target page. Can somebody point me in the right direction or give me a link to a tutorial or blog post that explains this scenario? Thanks

Original source