Ask Your Question
0

How to provide the workspace path as a file to setReportDir in XmlTestRunListener using groovy?

asked 2022-02-26 11:00:00 +0000

huitzilopochtli gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-12-18 07:00:00 +0000

nofretete gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-02-26 11:00:00 +0000

Seen: 14 times

Last updated: Dec 18 '21