Reputation: 2576
I have used below line to identify the html file. But It returned exception.
def location=${workspace}/report_${BUILD_NUMBER}
println(location)
def report=build.getWorkspace().child(location+"/report.html")
Exception Observed:
groovy.lang.MissingPropertyException: No such property: workspace for class: groovy.lang.Binding at groovy.lang.Binding.getVariable(Binding.java:63) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:224) at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241) at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238) at org.kohsuke.groovy.sandbox.impl.Checker$checkedGetProperty.callStatic(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:230) at Script1.run(Script1.groovy:1)
Anybody can help me how to get the current workspace and append that value into some string like below:
location+"/report.html"
Upvotes: 0
Views: 783
Reputation: 28634
try this:
build.getWorkspace().child("report_${BUILD_NUMBER}/report.html")
instead of report.html
you can define the path relative to workspace directory. it should be without /
at the beginning.
if you are not sure about directory structure, you can try to list files in workspace directory:
build.getWorkspace().list().each{ println it }
Upvotes: -1