-
Bug
-
Resolution: Not A Defect
-
Minor
-
None
Related to JENKINS-28701
The following script executes just fine in script console, but the import throws an error in job console output. I looked at a ticket with an almost identical name, but I don't fully grasp how to solve the problem.
I got the base script from another user and made some minor modifications to make it fit the intended purpose:
import hudson.plugins.shelveproject.ShelveProjectTaskdef daysBack=45; Jenkins.instance.getAllItems(AbstractProject.class).each{ it-> def lastBuild=it.getLastBuild() if(it.name.startsWith("BuildThor") || it.name.startsWith("IntTestThor")){ if(lastBuild != null){ def back = Calendar.getInstance() back.set(Calendar.DAY_OF_YEAR,back.get(Calendar.DAY_OF_YEAR)-daysBack) if (lastBuild.getTime().compareTo(back.getTime()) < 0) { println it.name + " was built over " + daysBack + " days ago: " + lastBuild.getTime() if (it instanceof AbstractProject){ println " *****PROJECT SHELVED THIS ITERATION*****" def spt= new ShelveProjectTask(it) Hudson.getInstance().getQueue().schedule(spt , 0 ); } } } else{ println it.name + " was not shelved this iteration." } } }
ERROR: startup failed: script: 4: unable to resolve class hudson.plugins.shelveproject.ShelveProjectTask @ line 4, column 1. import hudson.plugins.shelveproject.ShelveProjectTask ^ 1 error