This might be what you are looking for:
https://wiki.jenkins-ci.org/display/JENKINS/Extension+points#Extensionpoints-hudson.model.TransientProjectActionFactory


Robert Sandell
Software Tools Engineer - Tools and Integration
Sony Mobile Communications


> -----Original Message-----
> From: [email protected] [mailto:jenkinsci-
> [email protected]] On Behalf Of maxitrompe
> Sent: den 17 april 2012 19:01
> To: [email protected]
> Subject: How to make a plugin like the SideBar plugin, but without
> having the user entering the name and URL of the links
> 
> Hello, I am trying to create a plugin on Jenkins that consists in
> displaying
> a link on the left sidebar of every job, which redirects the user to a
> new
> page.
> To start implementing my plugin, I downloaded the
> https://wiki.jenkins-ci.org/display/JENKINS/Sidebar-Link+Plugin SideBar
> Plugin , only this plugin displays a link on the side that is defined
> by the
> user in the configuration page of the jobs.
> The class that displays it is the following :
> 
>     package hudson.plugins.sidebar_link;
> 
>     import hudson.Extension;
>     import hudson.model.*;
>     import java.util.ArrayList;
>     import java.util.Collection;
>     import java.util.List;
>     import net.sf.json.JSONObject;
>     import org.kohsuke.stapler.DataBoundConstructor;
>     import org.kohsuke.stapler.StaplerRequest;
> 
> 
>     public class ProjectLinks extends
> JobProperty<AbstractProject&lt;?,?>>
>     {
>         private List<ActionClass> links = new ArrayList<ActionClass>();
> 
>     @DataBoundConstructor
>     public ProjectLinks(List<ActionClass> links)
>     {
>         this.links = links;
>     }
> 
>     public List<ActionClass> getLinks()
>     {
>         return links;
>     }
> 
>     @Override
>     public Collection<? extends Action>
> getJobActions(AbstractProject<?,?>
> job)
>     {
>         return links;
>     }
> 
> 
>     @Extension
>     public static class DescriptorImpl extends JobPropertyDescriptor
>     {
> 
>         @Override
>         public String getDisplayName()
>         {
>             return "Sidebar Links";
>         }
> 
>         @Override
>         public ProjectLinks newInstance(StaplerRequest req, JSONObject
> formData) throws Descriptor.FormException
>         {
>             return formData.has("sidebar-links")
>                     ? req.bindJSON(ProjectLinks.class,
> formData.getJSONObject("sidebar-links"))
>                     : null;
>             }
>         }
>     }
> 
> 
> The last function implemented here takes parameters entered by the user,
> sent via the jelly file coresponding:
> 
>     <?jelly escape-by-default='true'?>
>     <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler"
> xmlns:l="/lib/layout" xmlns:f="/lib/form">
> 
> 
>       <f:repeatable var="link" items="${attrs.links}" name="links"
> add="${%Add Link}">
>         <table class="sidebar_link">
>           <f:entry title="${%Link URL}"
> help="/plugin/sidebar-link/help-url.html">
>             <f:textbox name="urlName" value="${link.urlName}"/>
>           </f:entry>
>           <f:entry title="${%Link Text}">
>             <f:textbox name="displayName" value="${link.displayName}"/>
>           </f:entry>
>           <f:entry title="${%Link Icon}"
> help="/plugin/sidebar-link/help-icon.html">
>             <f:textbox name="iconFileName"
> value="${link.iconFileName}"/>
>           </f:entry>
>           <f:entry><f:repeatableDeleteButton/></f:entry>
>         </table>
>       </f:repeatable>
>     </j:jelly>
> 
> Does anyone knows how to make the same plugin, but without having the
> user
> entering the name of the link and its URL, which I think also means
> without
> a jelly file. I want the user to have a link on the side of every job
> existing, where I can display information about the job in a new page.
> 
> I have been looking over the net for the past few days and have found
> absolutely nothing.
> 
> If I wasn't clear enough, I apologize, I will give specification if
> needed.
> 
> Thank you in advance.
> 
> 
> 
> --
> View this message in context: http://jenkins.361315.n4.nabble.com/How-
> to-make-a-plugin-like-the-SideBar-plugin-but-without-having-the-user-
> entering-the-name-and-URL-os-tp4565404p4565404.html
> Sent from the Jenkins dev mailing list archive at Nabble.com.

Reply via email to