Hudson: developing plugin but it's not appearing on my main page?
I'm trying to add a link to the main page of my jenkins. After looking through some examples (I'm new at developing Jenkins plugins), it seems I just need to create a class that extends Notifier (you don't seem to need to define it anywhere else?) and override the perform step.
I tried both :
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launche开发者_开发问答r, BuildListener listener) throws InterruptedException, IOException {
List<Action> installedActions = Hudson.getInstance().getActions();
BuildMonitorAction action = new BuildMonitorAction();
if(!installedActions.contains(action)){
Hudson.getInstance().getActions().add(action);
}
return true;
}
And:
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
List<Action> installedActions = Hudson.getInstance().getActions();
for (Action installedAction: installedActions) {
if (installedAction instanceof BuildMonitorAction) {
return true;
}
}
BuildMonitorAction action = new BuildMonitorAction();
Hudson.getInstance().getActions().add(action);
return true;
}
But the perform action does not seem to be performed?
The BuildMonitorAction is just:
@ExportedBean (defaultVisibility = 999)
@Extension
public class BuildMonitorAction implements RootAction {
public String getDisplayName() {
return "grass is green";
}
public String getIconFileName() {
return null;
}
public String getUrlName() {
return "/buildmonitor";
}
}
Does anyone have any pointers as to why a link with display text "grass is green" isn't appearing in my main menu?
And another question: is there a way to clear the jenkins development workspace besides deleting it in my project folder? mvn clean doesn't seem to clear it.
Thank you in advance.
I don't know if anyone's looking for this anymore, but apparently having getIconFileName return null will hide the task from showing in your task bar:
http://hudson-ci.org/javadoc/hudson/model/Action.html#getIconFileName%28%29
I just had the method return a random string and it worked. (just the text showed, no broken image or anything)
精彩评论