I'm attempting to delete the build history from Jenkins using the instructions in this answer:
How do I clear my Jenkins/Hudson build history?
However, I'm getting the following error message:
groovy.lang.MissingMethodException: No signature of method: jenkins.branch.OrganizationFolder.getBuilds() is applicable for argument types: () values: [] Possible solutions: getViews(), doBuild(jenkins.util.TimeDuration), getUrl(), getClass(), getActions(), getApi() at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58) at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:49) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
If I run this script:
def jobName = "github-test"
def job = Jenkins.instance.getItem(jobName)
println(job)
I get the following output:
jenkins.branch.OrganizationFolder@134f3a3c[github-test]
I'm using version 2.32.2.
Here's the exact script that I ran:
def jobName = "github-test"
def job = Jenkins.instance.getItem(jobName)
job.getBuilds().each { it.delete() }
job.nextBuildNumber = 1
job.save()