Hudson:正在开发插件,但它没有出现在我的主页上?

发布于 2024-10-29 08:26:39 字数 1753 浏览 0 评论 0原文

我正在尝试添加一个指向我的詹金斯主页的链接。 在查看了一些示例之后(我是开发 Jenkins 插件的新手),似乎我只需要创建一个扩展 Notifier 的类(您似乎不需要在其他地方定义它?)并覆盖执行步骤。

我都尝试了:

@Override
    public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, 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;
}

和:

@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;
    }

但是执行动作似乎没有执行?

BuildMonitorAction 只是:

@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";
    }
}

有人知道为什么带有显示文本“草是绿色的”的链接没有出现在我的主菜单中吗?

还有一个问题:除了在我的项目文件夹中删除它之外,还有没有办法清除詹金斯开发工作区? mvn clean 似乎没有清除它。

先感谢您。

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 launcher, 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伪装你 2024-11-05 08:26:39

我不知道是否有人在寻找这个,但显然让 getIconFileName 返回 null 会隐藏任务,使其不显示在任务栏中:

http://hudson-ci.org/javadoc/hudson/model/Action.html#getIconFileName%28%29

我刚刚有这个方法返回一个随机字符串并且它起作用了。 (只显示文字,没有损坏的图像或任何东西)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文