embed svg created by d3 in plug-in

83 views
Skip to first unread message

Annie Jiao

unread,
Jun 30, 2015, 5:34:16 PM6/30/15
to jenkin...@googlegroups.com
is it possible to create an svg graphic (non-interactive) using D3 and embedding the result in a jenkins plug-in?

I do plan on making different parts of the svg clickable and link to other pages further down the road.

Thanks!

Ioannis Moutsatsos

unread,
Jul 1, 2015, 10:09:25 AM7/1/15
to jenkin...@googlegroups.com
I'm confused from the description of what you are trying to do.
Where is this SVG graphic going to be displayed?
  • Job level (ie is this going to be on the build UI) or
  • Build report level (ie part of the results after a build)
Depending on one of this options we can suggest some options.

Surya Gaddipati

unread,
Jul 1, 2015, 12:02:59 PM7/1/15
to jenkin...@googlegroups.com
Jenkins serves HTML pages. you should be able to embed your svg in jelly files.

Annie Jiao

unread,
Jul 1, 2015, 2:25:24 PM7/1/15
to jenkin...@googlegroups.com
this'll be on the job level -- as in

Ioannis Moutsatsos

unread,
Jul 1, 2015, 3:37:27 PM7/1/15
to jenkin...@googlegroups.com
So, will the SVG change as more builds are accumulated in the job history? It sounds like you want to use it for navigation purposes.
You can include a graphic in your project description using HTML, even an iFrame.

It will then display on the http://localhost:8080/jenkins/job/jobname/ page

Annie Jiao

unread,
Jul 1, 2015, 6:37:51 PM7/1/15
to jenkin...@googlegroups.com
Yup, the svg will change to reflect data as new builds occur. (The navigation is secondary)

Do I need to install any plug-ins to use an iFrame?

Thanks a lot for your help!

Ioannis Moutsatsos

unread,
Jul 1, 2015, 8:17:57 PM7/1/15
to jenkin...@googlegroups.com
No special plugin needed. 
You should be able to add some standard HTML (including an iframe) element to a project's description and it will be displayed when the job page is rendered. Take a look here where I've added an animated gif to demo how a build is executed.

Hope this helps to get you started.

Annie Jiao

unread,
Jul 6, 2015, 5:41:13 PM7/6/15
to jenkin...@googlegroups.com
This has been incredibly helpful! Thanks!

I see that it reads data from a csv file. Is there a way to populate it with data from the builds, instead of a preset file? (Suppose I want to plot % of builds that passed everyday for the past week).

Bruno P. Kinoshita

unread,
Jul 6, 2015, 6:37:23 PM7/6/15
to jenkin...@googlegroups.com
If you are using Groovy, you can use Jenkins API to retrieve this kind of information. You can have a look at some of the Scriptler scripts https://scriptlerweb.appspot.com/catalog/list, and also check examples in the Groovy plug-in, StackOverflow and also check Jenkins' source code https://github.com/jenkinsci/jenkins

HTH
Bruno


From: Annie Jiao <annie...@gmail.com>
To: jenkin...@googlegroups.com
Sent: Tuesday, July 7, 2015 9:41 AM
Subject: Re: embed svg created by d3 in plug-in

This has been incredibly helpful! Thanks!

I see that it reads data from a csv file. Is there a way to populate it with data from the builds, instead of a preset file? (Suppose I want to plot % of builds that passed everyday for the past week).


On Wednesday, July 1, 2015 at 5:17:57 PM UTC-7, Ioannis Moutsatsos wrote:
No special plugin needed. 
You should be able to add some standard HTML (including an iframe) element to a project's description and it will be displayed when the job page is rendered. Take a look here where I've added an animated gif to demo how a build is executed.

Hope this helps to get you started.



On Wednesday, July 1, 2015 at 6:37:51 PM UTC-4, Annie Jiao wrote:
Yup, the svg will change to reflect data as new builds occur. (The navigation is secondary)

Do I need to install any plug-ins to use an iFrame?

Thanks a lot for your help!

On Wednesday, July 1, 2015 at 12:37:27 PM UTC-7, Ioannis Moutsatsos wrote:
So, will the SVG change as more builds are accumulated in the job history? It sounds like you want to use it for navigation purposes.
You can include a graphic in your project description using HTML, even an iFrame.

It will then display on the http://localhost:8080/ jenkins/job/jobname/ page


On Wednesday, July 1, 2015 at 2:25:24 PM UTC-4, Annie Jiao wrote:
this'll be on the job level -- as in



On Wednesday, July 1, 2015 at 7:09:25 AM UTC-7, Ioannis Moutsatsos wrote:
I'm confused from the description of what you are trying to do.
Where is this SVG graphic going to be displayed?
  • Job level (ie is this going to be on the build UI) or
  • Build report level (ie part of the results after a build)
Depending on one of this options we can suggest some options.

On Tuesday, June 30, 2015 at 5:34:16 PM UTC-4, Annie Jiao wrote:
is it possible to create an svg graphic (non-interactive) using D3 and embedding the result in a jenkins plug-in?

I do plan on making different parts of the svg clickable and link to other pages further down the road.

Thanks!
--
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/19aa8409-edfd-4121-9674-579e4052bf2b%40googlegroups.com.



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


Annie Jiao

unread,
Jul 6, 2015, 8:12:07 PM7/6/15
to jenkin...@googlegroups.com, brunod...@yahoo.com.br
https://scriptlerweb.appspot.com/script/show/426002

This looks great for what I'm trying to do. I added that as an "active choice reactive reference parameter" with the reference parameter field blank, and I do see the title when I click "build with parameters", but nothing is printed to the HTML, the browser console, or the Logger Console. Where should i be looking for the output?

Thank you so much!

Bruno P. Kinoshita

unread,
Jul 6, 2015, 8:36:52 PM7/6/15
to jenkin...@googlegroups.com
I can try that later in a testing instance that we use to develop the plug-in, but if you haven't modified the script, the output is probably in the Jenkins logs (see [1] and [2]).

If you want to display that as parameters, the Active Choices plug-in expects your script to return an array of strings, being each string rendered as a parameter of the type selected (e.g. combo box, radio, input text, etc).

Hope that helps
Bruno



Cc: brunod...@yahoo.com.br
Sent: Tuesday, July 7, 2015 12:12 PM

Subject: Re: embed svg created by d3 in plug-in
https://scriptlerweb.appspot.com/script/show/426002

This looks great for what I'm trying to do. I added that as an "active choice reactive reference parameter" with the reference parameter field blank, and I do see the title when I click "build with parameters", but nothing is printed to the HTML, the browser console, or the Logger Console. Where should i be looking for the output?

Thank you so much!


On Monday, July 6, 2015 at 3:37:23 PM UTC-7, kinow wrote:
If you are using Groovy, you can use Jenkins API to retrieve this kind of information. You can have a look at some of the Scriptler scripts https://scriptlerweb.appspot. com/catalog/list, and also check examples in the Groovy plug-in, StackOverflow and also check Jenkins' source code https://github.com/jenkinsci/ jenkins

Annie Jiao

unread,
Jul 9, 2015, 9:24:06 PM7/9/15
to jenkin...@googlegroups.com, brunod...@yahoo.com.br
Thanks a lot everyone! The scripts library is also very helpful. I'm now having trouble getting the timestamps of a build — for each project, I want to iterate through all the builds and get the timestamps. There's the method getTimeInMillis() that I would like to use, from the api (http://javadoc.jenkins-ci.org/hudson/model/Run.html), but I don't know how to access that when I'm iterating over Hudson.instance.items .

Annie Jiao

unread,
Jul 10, 2015, 5:39:09 PM7/10/15
to jenkin...@googlegroups.com, brunod...@yahoo.com.br
Actually the output from http://localhost:8080/jenkins/job/job-name/api/json?tree=builds[timestamp] is exactly what I need. Is there a way to get this pragmatically in the groovy script?

Bruno P. Kinoshita

unread,
Jul 11, 2015, 4:58:42 AM7/11/15
to jenkin...@googlegroups.com
Hi Annie

Maybe something like

```
def job = Jenkins.instance.getItem("<job-name>")
job.builds.each() {
  //println(it.timestamp)
  println(it.timeInMillis)
}
```

The timestamp returns a calendar, and the timeInMillis the long value.

I have Jenkins in my Eclipse workspace, and usually first take a look at github.com/jenkinsci/jenkins, but if
I cannot find what I'm after, I debug the call (e.g. from Api.java or Build.java) and look at the objects used, and how I could use them in Groovy.

Hope that helps,
Bruno


Cc: brunod...@yahoo.com.br
Sent: Saturday, July 11, 2015 9:39 AM
Reply all
Reply to author
Forward
0 new messages