Quantcast

Displaying Images with Jelly

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Displaying Images with Jelly

LordShacks
Hi

I am new to Jenkins and am writing a custom plugin similar to CppCheck that takes in XML files from a test unit and displays the results as a graph.

I have successfully created a graph from my XML file and saved this to disk as a .png file. I am now trying to get my ProjectAction's index.jelly file to display this graph image.

I have seen from other plugins (Cppcheck) that this should be achievable by simply using the html tag < img/ >. I have tried doing this but I cannot seem to get the image to display.

I am unsure what to put for the src section of the image tag. If I simply put < img src="graph.png"/ >, (as I have done for icons) nothing get's displayed. I have also tried to specify the directory on my system where the file is located: < img src="/home/user/Desktop/graph.png"/ > but it still does not display the graph. Where do I have to have the graph file located so that the index.jelly file can find it?

Many thanks

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Displaying Images with Jelly

mpapo - Michaël Pailloncy

Hi,

 

You can access to images of your plugin like this : 

- add your images to src/main/webapp/images in your project

- add your image in your jelly file like this : <img src="${rootURL}/plugin/yourPluginName/images/yourIcon.png"/>

 

${rootURL} refers to the root path of Jenkins.

 

Michaël


2012/10/25 LordShacks <[hidden email]>
Hi

I am new to Jenkins and am writing a custom plugin similar to CppCheck that
takes in XML files from a test unit and displays the results as a graph.

I have successfully created a graph from my XML file and saved this to disk
as a .png file. I am now trying to get my ProjectAction's index.jelly file
to display this graph image.

I have seen from other plugins (Cppcheck) that this should be achievable by
simply using the html tag < img/ >. I have tried doing this but I cannot
seem to get the image to display.

I am unsure what to put for the src section of the image tag. If I simply
put < img src="graph.png"/ >, (as I have done for icons) nothing get's
displayed. I have also tried to specify the directory on my system where the
file is located: < img src="/home/user/Desktop/graph.png"/ > but it still
does not display the graph. Where do I have to have the graph file located
so that the index.jelly file can find it?

Many thanks





--
View this message in context: http://jenkins.361315.n4.nabble.com/Displaying-Images-with-Jelly-tp4644335.html
Sent from the Jenkins dev mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Displaying Images with Jelly

Ulli Hafner

Am 31.10.2012 um 09:45 schrieb Michaël Pailloncy <[hidden email]>:

> Hi,
>
>  
> You can access to images of your plugin like this :
>
> - add your images to src/main/webapp/images in your project
>
> - add your image in your jelly file like this : <img src="${rootURL}/plugin/yourPluginName/images/yourIcon.png"/>
>
>  
> ${rootURL} refers to the root path of Jenkins.
>


You should better use ${resURL}, see the following post for details:

http://jenkins.361315.n4.nabble.com/ANN-Referring-to-static-resources-from-your-plugin-td4490655.html

Ulli

>  
> Michaël
>
>
> 2012/10/25 LordShacks <[hidden email]>
> Hi
>
> I am new to Jenkins and am writing a custom plugin similar to CppCheck that
> takes in XML files from a test unit and displays the results as a graph.
>
> I have successfully created a graph from my XML file and saved this to disk
> as a .png file. I am now trying to get my ProjectAction's index.jelly file
> to display this graph image.
>
> I have seen from other plugins (Cppcheck) that this should be achievable by
> simply using the html tag < img/ >. I have tried doing this but I cannot
> seem to get the image to display.
>
> I am unsure what to put for the src section of the image tag. If I simply
> put < img src="graph.png"/ >, (as I have done for icons) nothing get's
> displayed. I have also tried to specify the directory on my system where the
> file is located: < img src="/home/user/Desktop/graph.png"/ > but it still
> does not display the graph. Where do I have to have the graph file located
> so that the index.jelly file can find it?
>
> Many thanks
>
>
>
>
>
> --
> View this message in context: http://jenkins.361315.n4.nabble.com/Displaying-Images-with-Jelly-tp4644335.html
> Sent from the Jenkins dev mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Displaying Images with Jelly

Jesse Glick-4
In reply to this post by mpapo - Michaël Pailloncy
On 10/31/2012 04:45 AM, Michaël Pailloncy wrote:
> add your images to src/main/webapp/images

Useless for dynamically generated images.

Stapler-bind a hudson.util.Graph from your action so it is accessible from a dynamic URL. ProjectDiskUsageAction [1] [2] is a good example.

[1] https://github.com/jenkinsci/disk-usage-plugin/blob/master/src/main/java/hudson/plugins/disk_usage/ProjectDiskUsageAction.java
[2] https://github.com/jenkinsci/disk-usage-plugin/blob/master/src/main/resources/hudson/plugins/disk_usage/DiskUsageAction/floatingBox.jelly
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Displaying Images with Jelly

mpapo - Michaël Pailloncy
Thanks for the tips :-)
Is there a wiki page explaining this feature ?

Michaël

Le 01/11/2012 15:14, Jesse Glick a écrit :

> On 10/31/2012 04:45 AM, Michaël Pailloncy wrote:
>> add your images to src/main/webapp/images
>
> Useless for dynamically generated images.
>
> Stapler-bind a hudson.util.Graph from your action so it is accessible
> from a dynamic URL. ProjectDiskUsageAction [1] [2] is a good example.
>
> [1]
> https://github.com/jenkinsci/disk-usage-plugin/blob/master/src/main/java/hudson/plugins/disk_usage/ProjectDiskUsageAction.java
> [2]
> https://github.com/jenkinsci/disk-usage-plugin/blob/master/src/main/resources/hudson/plugins/disk_usage/DiskUsageAction/floatingBox.jelly

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Displaying Images with Jelly

Jesse Glick-4
On 11/02/2012 08:35 AM, Michael Pailloncy wrote:
> Is there a wiki page explaining this feature?

Not that I know of. Get it working in your plugin and add such a page! Or better yet, make sure (*) the Javadoc for Graph includes all the details you need to know, then
link to this Javadoc page [1] from some developer-oriented wiki page.

(*) I.e. pull request if necessary.

[1] http://javadoc.jenkins-ci.org/hudson/util/Graph.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Displaying Images with Jelly

LordShacks
In reply to this post by mpapo - Michaël Pailloncy
Followed these steps and the graph is being displayed perfectly.
 
Many thanks for your help!

On Wednesday, October 31, 2012 8:45:43 AM UTC, mpapo - Michaël Pailloncy wrote:

Hi,

 

You can access to images of your plugin like this : 

- add your images to src/main/webapp/images in your project

- add your image in your jelly file like this : <img src="${rootURL}/plugin/yourPluginName/images/yourIcon.png"/>

 

${rootURL} refers to the root path of Jenkins.

 

Michaël


2012/10/25 LordShacks <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="kw6j7qdSenYJ">chris....@...>
Hi

I am new to Jenkins and am writing a custom plugin similar to CppCheck that
takes in XML files from a test unit and displays the results as a graph.

I have successfully created a graph from my XML file and saved this to disk
as a .png file. I am now trying to get my ProjectAction's index.jelly file
to display this graph image.

I have seen from other plugins (Cppcheck) that this should be achievable by
simply using the html tag < img/ >. I have tried doing this but I cannot
seem to get the image to display.

I am unsure what to put for the src section of the image tag. If I simply
put < img src="graph.png"/ >, (as I have done for icons) nothing get's
displayed. I have also tried to specify the directory on my system where the
file is located: < img src="/home/user/Desktop/graph.png"/ > but it still
does not display the graph. Where do I have to have the graph file located
so that the index.jelly file can find it?

Many thanks





--
View this message in context: http://jenkins.361315.n4.nabble.com/Displaying-Images-with-Jelly-tp4644335.html
Sent from the Jenkins dev mailing list archive at Nabble.com.

Loading...