Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can provide the workspace path as a file to setReportDir in XmlTestRunListener using the following Groovy code:

import hudson.model.*
import hudson.util.*

def build = Thread.currentThread().executable
def workspace = build.workspace
def reportDir = new FilePath(workspace, "path/to/report/dir")

def listener = new XmlTestRunListener()
listener.setReportDir(reportDir)

In the above code, you first get the current build object using Thread.currentThread().executable. Then, you get the workspace path of the build using build.workspace. After that, you create a FilePath object for the desired report directory within the workspace. Finally, you create a new XmlTestRunListener object and call setReportDir method on it, passing the reportDir object as an argument.