Hi, I have some newbie questions

96 views
Skip to first unread message

Manu Kaamelott

unread,
Nov 5, 2015, 5:55:32 AM11/5/15
to Jenkins Developers
Hi everyone, (sorry for my english and maybe I didn't use the right jenkins' words)
I start jenkins and write plugin for it 2 month ago. I search a lot of and found some exemple in the other plugin like add column in the main page and write report in the build page.
But I didn't understand how write something in the main job page. I found mainJob.jelly but that didn't work.
I'd like to know how can I write in it. Can I use juste a ".java and .jelly" ?
Thanks for your help !

Daniel Beck

unread,
Nov 5, 2015, 7:11:24 AM11/5/15
to jenkin...@googlegroups.com

On 05.11.2015, at 11:55, Manu Kaamelott <manuka...@gmail.com> wrote:

> But I didn't understand how write something in the main job page. I found mainJob.jelly but that didn't work.
> I'd like to know how can I write in it. Can I use juste a ".java and .jelly" ?

Hi Manu,

First, you need to define an Action that gets associated with the Job you have.

One way to do this is TransientActionFactory, assuming you have no data to store with the job. And if you do, you need something that explicitly adds the Action to the job, and then saves the job.

Afterwards it's just a matter of adding a jobMain.jelly view to the Action, so in the regular Maven layout:

If this is your Action class: src/main/java/com/acme/my_plugin/MyAction.java
This is the Jelly view fragment shown on the job page: src/main/resources/com/acme/my_plugin/MyAction/jobMain.jelly

So it's not a Jelly file corresponding to the Java file, but rather one stored in a folder with the same name as the class and with a name determined by convention (e.g. config.jelly for parts of the job config).

Daniel

Manu Kaamelott

unread,
Nov 10, 2015, 5:54:06 AM11/10/15
to Jenkins Developers, m...@beckweb.net
Hi thank you Daniel,
I don't understand very well what is an action. I read this I think I didn't understand enough :

I am sure I have to write in type and creatFor but I don't understand what. Thank you for the future answers.
Hope I explain very well :) !
Manu

I have this file:
FPJTransientActionFactory.java
@Extension
public class FPJTransientActionFactory extends TransientActionFactory<Flag>{


   
private Job job;
   
public List warningGet = new LinkedList();
   
public List errorGet = new LinkedList();
   
   
public String getJobsFlag() throws IOException, RedmineException{
       
Flag jobFlag = new Flag();
       
String flag = jobFlag.getFlag(job);
       
       
//List of warnings and errors
        warningGet
= jobFlag.getWarning();
        errorGet
= jobFlag.getError();
       
return flag;
   
}
   
@Override
   
public Class<Flag> type() {
       
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
   
}
   
@Override
   
public Collection<? extends Action> createFor(Flag t) {
       
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
   
}
}

jobMain.jelly
<j:jelly xmlns:j="jelly:core">
   
<!-- TODO -->
   
<link rel="stylesheet" href ="${rootURL}/plugin/redmine/css/styleFlag.css" type="text/css"/>
   
   
<table class="tableau">
       
<tr>
           
<th>Drapeau</th>
           
<th>Erreur</th>
           
<th>Warning</th>
       
</tr>
       
<tr>
           
<td>${it.jobsFlag}</td>
           
<td>
               
<j:forEach var="error" items="${it.errorGet}">
                    ${error}
<br />
               
</j:forEach>
           
</td>
           
<td>
               
<j:forEach var="warning" items="${it.warningGet}">
                    ${warning}
               
</j:forEach>
           
</td>
       
</tr>
   
</table>
</j:jelly>

Robert Sandell

unread,
Nov 11, 2015, 4:57:06 AM11/11/15
to jenkin...@googlegroups.com
The type for the transientActionFactory should be the type you want to provide Actions for. for example Job, View or Run etc.

TransientActionFactory<Job>

If you specify that then I don't think you need to implement the type method.

/B

--
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/4634b067-4456-4ca4-866d-b77da0027c66%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Robert Sandell
Software Engineer
CloudBees Inc.
Reply all
Reply to author
Forward
0 new messages