To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/D4EE56B0-1745-473E-B947-016C794E484F%40beckweb.net.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/DM2PR05MB717882B9F62A082C8CB1AC5B8590%40DM2PR05MB717.namprd05.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.
Perfect – thanks!
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CA%2BWW-yZkoJwTN6mPGEoz-ZVmpqypAvGbvsD5AY7xTQXWZS4Eog%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/DM2PR05MB7172EE3C711FE6794E5192AB8590%40DM2PR05MB717.namprd05.prod.outlook.com.
Was going to use a shell script, but maybe it’s a good time to learn some Groovy.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CA%2BWW-yYc%2BjCE7P0VmczPwyTOgE2Z2709KMSgPLANVUZsTUYuUw%40mail.gmail.com.
Here’s my groovy script to run with script trigger. Looks like everything works, except I assumed the return value of 0 would schedule a build (this seems to be the way it works when a shell script is used). I’m guessing that when groovy is used with script trigger, I need to call the build command from within the groovy script?
println("Checking time of last successful run to determine if regression is needed")
def item = hudson.model.Hudson.instance.getItem("$JOB_NAME")
def build = item.getLastSuccessfulBuild()
def last_success_time = build.getTime()
println(last_success_time.time)
def today = new Date()
def hours_since_run = (today.time - last_success_time.time) / (60 * 60 * 1000)
println hours_since_run
if (hours_since_run < 20)
{
println("Ran successfully $hours_since_run ago, skipping automatic regression")
return 1
}
else
{
println("Running regression")
return 0
I didn’t notice that the return value should be ‘true’ for groovy scripts. This script works great. The only drawback I’ve seen of using script trigger vs the built in scheduling is script trigger is not compatible with next executions, you will not see the next time the script will be evaluated.
Thanks again for the help!
println("Checking time of last successful run to determine if regression is needed")
def item = hudson.model.Hudson.instance.getItem("$JOB_NAME")
def build = item.getLastSuccessfulBuild()
def last_success_time = build.getTime()
println(last_success_time.time)
def today = new Date()
def hours_since_run = (today.time - last_success_time.time) / (60 * 60 * 1000)
println hours_since_run
if (hours_since_run < 20)
{
println("Ran successfully $hours_since_run ago, skipping automatic regression")
return false
}
else
{
println("Running regression")
return true
}