delete all build queue jenkins code example
Example: jenkins delete all builds of a job
def jobName = "KPI_Measurements/KPI_Build_delete/KPI_delete_build"
def job = Jenkins.getInstance().getItemByFullName(jobName, Job.class)
job.getBuilds().each { it.delete() }
job.nextBuildNumber = 1
job.save()