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.
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
Asked: 2022-02-26 11:00:00 +0000
Seen: 14 times
Last updated: Dec 18 '21
How to choose specific parameters while selecting inputs in Jenkins (Groovy) Pipeline?
How to modify the node label in Jenkins once the job has been completed successfully?
What are the typical approaches found in a Gradle build script?
How can a list of objects in Groovy be created from Json?
What is the method to invoke a function within Gradle's `pluginManagement {}` section?
What is the reason for the convertibility of variable types in a Groovy class?