First you need to install Groovy Script plugin. (This is just one way of doing this)
You can go to plugin manager and Install the groovy plugin.
After Installing it will look like following.
Now got to the build you configured and add a Pre-Build Steps and select "Execute system Groovy script."
Now add the following script as the body.
import hudson.model.* def build = Thread.currentThread().executable def today = new Date() def pa = new ParametersAction([new StringParameterValue("DATE",today.toString())]) build.addAction(pa)
With the above code snippet I have added the system date to a variable called "DATE". After setting this should be accessible within the job context with the following syntax.
$DATE
${DATE}queries.
Hope this will help someone interested and please drop a comment if you have any queries.
No comments:
Post a Comment