Reputation: 9967
I'm just getting started writing plugins for Jenkins, and I'm having trouble making much headway in the exceptionally terse documentation I've been able to find for it. The main thing I'm trying to do is generate dynamic content to place on the top-level page for a particular Project. Specifically, I want to show some content that is derived from the most recent build of the Project.
Based on the skeleton project and the HTMLPublisher plugin, I've been able to create a Publisher
plugin that creates an Action with getProjectActions
, and that Action has a floatingBox.jelly
view, whose contents are rendered at the top of the Project page. So far, so good.
Now I want to make that content dynamic. For instance, my Publisher plugin might generate some HTML content as a post-build step, and I want to display this HTML (from the latest build) at the top of the Project page. Or (more likely), I'll want to generate some HTML based on all builds, and display that (e.g., a plot showing some some kind of "quality mesaurement" for each of the last N builds).
I'm brand new to maven and jelly, and quite new to Jenkins for that matter, so any help would be useful.
I've found that I can use ${it}
inside my jelly scripts to access the Project
object, but can I then access my Publisher
instance from there, in order to invoke some methods on it to generate the content?
Upvotes: 1
Views: 1097
Reputation: 9967
The only thing I've come up with so far is to iterate over the list of publishers provided by getPublishersList()
on the Project
object, and look for one whose class name matches my class. I can't find a way to do instanceof
in jelly script.
<j:forEach items="${it.publishersList}" var="pub">
<j:if test='${pub.class.name == "com.example.myPluginName.myPublisherClassName"}'>
<!-- ${pub} is my Publisher instance, I can now invoke methods on it. -->
</j:if>
</j:forEach>
Alternatively, if you use jobMain.jelly
instead of floatingBox.jelly
, in that case ${it}
is the Action
itself.
Upvotes: 1