Is it an 'Execute Groovy script' build step? If so, you need an 'Execute system 
Gorovy script' build step instead.

On 30.04.2014, at 03:48, Maneesh M P <[email protected]> wrote:

> I am trying to execute a Groovy script as build step, I am getting below 
> error. Can anyone tell me how to resolve this ?
> 
> 
> var/lib/jenkins/jobs/abc/workspace/hudson905310450711762336.groovy: 4: unable 
> to resolve class hudson.model.Job
>  @ line 4, column 1.
>    import hudson.model.Job;
>    ^
> 
> /var/lib/jenkins/jobs/abc/workspace/hudson905310450711762336.groovy: 20: 
> unable to resolve class hudson.model.Fingerprint.RangeSet
>  @ line 20, column 1.
>    import hudson.model.Fingerprint.RangeSet;
>    ^
> 
> /var/lib/jenkins/jobs/abc/workspace/hudson905310450711762336.groovy: 5: 
> unable to resolve class hudson.model.Fingerprint
>  @ line 5, column 1.
>    import hudson.model.Fingerprint;
>    ^
> 
> 3 errors
> 
>  
> Groovy Script :
> ===================
> 
> import groovy.json.*
> import jenkins.model.*;
> import hudson.model.Fingerprint.RangeSet;
> import hudson.model.Job;
> import hudson.model.Fingerprint;
> 
> // NOTE: Uncomment parameters below if not using Scriptler >= 2.0, or if 
> you're just pasting the script in manually.
> // ----- Logic in this script takes 5000 as the infinite number, decrease / 
> increase this value from your own experience.
> // The name of the job.
> def jobName = "maneesh-try"
> 
> // The range of build numbers to delete.
> def buildNumber = "272"
> 
> def lastBuildNumber = buildNumber.toInteger() - 1;
> def nextBuildNumber = buildNumber.toInteger() + 1;
> 
> 
> import jenkins.model.*;
> import hudson.model.Fingerprint.RangeSet;
> 
> def jij = jenkins.model.Jenkins.instance.getItem(jobName);
> 
> println("Keeping Job_Name: ${jobName} and build Number: ${buildNumber}");
> println ""
> 
> def setBuildRange = "1-${lastBuildNumber}"
> def range = RangeSet.fromString(setBuildRange, true);
> jij.getBuilds(range).each { it.delete() }
> println("Builds have been deleted - Range: " + setBuildRange)
> 
> setBuildRange = "${nextBuildNumber}-5000"
> range = RangeSet.fromString(setBuildRange, true);
> jij.getBuilds(range).each { it.delete() }
> println("Builds have been deleted - Range: " + setBuildRange)
> 
> thank,s
> Maneesh
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to