Skip to content

Instantly share code, notes, and snippets.

@cvakiitho
Last active July 16, 2021 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cvakiitho/3c1cf58eb6a5becf30ad81a6efc12d21 to your computer and use it in GitHub Desktop.
Save cvakiitho/3c1cf58eb6a5becf30ad81a6efc12d21 to your computer and use it in GitHub Desktop.
remove branch indexing from build queue jenkins
import hudson.model.*
import jenkins.model.Jenkins
def timer = 5000 //5s timer
def counter = 12 * 10 // 10 minutes reruns
for (i = 0; i <counter; i++) {
def q = Jenkins.instance.queue
println("$i / ${counter}")
q.items.findAll { def causes = it.getCauses()
try {
return causes[0].getShortDescription() == 'Branch indexing'
} catch (e){}
}.each {
q.cancel(it.task)
}
sleep(timer)
}
@cvakiitho
Copy link
Author

This script checks each 5s for 10 minutes,
if there are builds from branch indexing in the queue and cancels them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment