Hello-world plugin example; unable to get side menu to appear

52 views
Skip to first unread message

Bob Pokorny

unread,
Aug 10, 2023, 4:20:53 PM8/10/23
to Jenkins Developers

Hi there –

 

I am following the Hello-World plug-in tutorial and attempting to extend it.  I am following the instructions outlined in the documentation; however, I am unable to get the side menu to appear.

 

This is the code for HelloWorldAction:

package io.jenkins.plugins.sample;

import hudson.model.Run;
import jenkins.model.RunAction2;

public class HelloWorldAction implements RunAction2 {

    private String name;
    private transient Run run;

    public HelloWorldAction(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    @Override
    public String getIconFileName() {
        return "document.png";
    }

    @Override
    public String getDisplayName() {
        return "Greeting";
    }

    @Override
    public String getUrlName() {
        return "greeting";
    }

    @Override
    public void onAttached(Run<?, ?> r) {
        this.run = run;
    }

    @Override
    public void onLoad(Run<?, ?> r) {
        this.run = run;    
    }

    public Run getRun() {
        return run;
    }

}

Here is the index.jelly code:

 <?jelly escape-by-default='true'?>

<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout" xmlns:st="jelly:stapler">
    <l:layout title="Greeting">
        <l:side-panel>
            <st:include page="sidepanel.jelly" it="${it.run}" optional="true" />
        </l:side-panel>

        <l:main-panel>
            <h1>
                Name: ${it.name}
            </h1>
        </l:main-panel>
    </l:layout>
</j:jelly>

I don’t see the build menu on the left as the documentation describes.  I continue to only see the greeting.

I am brand new to Jenkins and plug-ins.  I know I have a long way to go to learn how to build a robust plug-in, therefore I want to make sure I understand why this is not working.

I appreciate your time.

 Thanks,

Bob

 

 

 

Winter, Markus

unread,
Aug 10, 2023, 4:42:47 PM8/10/23
to jenkin...@googlegroups.com

The sidepanel.jelly of a run already contains a <l:side-panel>, so you would have this doubled.

Maybe you can try this like this:

 

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout" xmlns:st="jelly:stapler">
    <l:layout title="Greeting">

        <st:include page="sidepanel.jelly" it="${it.run}" optional="true" />


        <l:main-panel>
            <h1>
                Name: ${it.name}
            </h1>
        </l:main-panel>
    </l:layout>
</j:jelly>

 

 

From: jenkin...@googlegroups.com <jenkin...@googlegroups.com> On Behalf Of Bob Pokorny
Sent: Donnerstag, 10. August 2023 21:54
To: Jenkins Developers <jenkin...@googlegroups.com>
Subject: Hello-world plugin example; unable to get side menu to appear

 

You don't often get email from rcpo...@gmail.com. Learn why this is important

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/c4ba5df6-a474-4afd-9222-f4985c861197n%40googlegroups.com.

Gavin Mogan

unread,
Aug 10, 2023, 4:49:46 PM8/10/23
to Jenkins Developers
Also did you add the action to anything? I think the hello world has a build wrapper that calls addaction

Otherwise you need a factory or extend root action to make it independent.

Gavin 

Bob Pokorny

unread,
Aug 10, 2023, 6:26:46 PM8/10/23
to Jenkins Developers
Thank you for the replies.

I did create the HelloWorldAction class that implements RunAction2.

Additionally, I did change the HelloWorldAction\index.jelly to include the side bar, but that didn't seem to have an effect.
Reply all
Reply to author
Forward
0 new messages