Details
-
Bug
-
Status: Fixed but Unreleased (View Workflow)
-
Blocker
-
Resolution: Not A Defect
-
None
Description
Hi,
I am trying to capture few values from the output window using Groovy script - Regular expressions. I have observed that the captured value is not being saved into newly created string parameter. Please find below the grrovy script which was used.
Jenkins version - 2.73.2
Promoted Build plugin version - 2.31
I have gone through few blogs and its been suggested to change system properties with the below statment but I am getting an error while running the same.
hudson.model.ParametersAction.safeParameters to a comma-separated list of safe parameter names
import hudson.model.*
def matcher = manager.getLogMatcher('setting scenario result folder to (.*)LRR$')
if (matcher.matches()) {
resDir=matcher.group(1)
manager.build.addAction(
new ParametersAction([
new StringParameterValue("RES_DIR", "${resDir}")
])
)
}
manager.listener.logger.println "${resDir}"
manager.listener.logger.println "$RES_DIR" - getting error for this statement
matcher = manager.getLogMatcher('DATE.*)$')
if (matcher.matches()) {
buildDate=matcher.group(1)
manager.build.addAction(
new ParametersAction([
new StringParameterValue("RES_TIMESTAMP", "${buildDate}")
])
)
}
manager.listener.logger.println("Hello 1");
manager.listener.logger.println "$RES_TIMESTAMP";- getting error for this statement
Groovy script failed:
groovy.lang.MissingPropertyException: No such property: RES_DIR for class: Script1 at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53) at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307) at Script1.run(Script1.groovy:19) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:585) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:623) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:594) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:170) at org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder.perform(GroovyPostbuildRecorder.java:362) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:736) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:682) at hudson.model.Build$BuildExecution.post2(Build.java:186) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:627) at hudson.model.Run.execute(Run.java:1762) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:421)