简体   繁体   中英

How to display a plot in Jenkins with Groovy script?

I'm currently trying to display the plot of an XML file in Jenkins by using a system Groovy script .

import hudson.plugins.plot.*

def plot = new Plot(csvFileName: "random.csv",
                    series: [[file: "report_cpu_sum.callisto.xml",
                              xpath: "xmllog/*",
                              nodeType: "NODESET",
                              url: ""]],
                    exclZero: false,
                    group: 'Groovy_CPU')

I can successfully create the plot object , but after reading the API docs for the plot plugin I can't understand how I actually display the plot object I just created. At first I thought I would do something like:

def pub = new PlotPublisher()
pub.addPlot(plot)
pub.getRequiredMonitorService()

However, the ouput of this is simply: script returned: BUILD

Any ideas?

Turns out that the way to go for using plots with Groovy code in Jenkins is with a Pipeline project.

These projects even have access to a 'Snippet Generator' that helps with creating your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM