Skip to content

Instantly share code, notes, and snippets.

@jonesbusy
Last active November 21, 2020 13:49
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 jonesbusy/e3a6119ad86a569cdf769e107ef31805 to your computer and use it in GitHub Desktop.
Save jonesbusy/e3a6119ad86a569cdf769e107ef31805 to your computer and use it in GitHub Desktop.
Force the Rescan of all multibranch pipelines and organisation folders
def scannableItems = jenkins.model.Jenkins.instance.getAllItems(org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject) +
jenkins.model.Jenkins.instance.getAllItems(jenkins.branch.OrganizationFolder)
scannableItems.collect { jenkins.model.Jenkins.getInstance().getQueue().schedule(it, 0, null, null)}.each { waitingItem ->
def future
def result
try {
future = waitingItem.getFuture()
result = future.get(timeout, TimeUnit.SECONDS)
println("${result} : ${result.getResult()}. Took ${result.getEstimatedDuration() / 1000.0} seconds")
}
catch (e) {
println("Unable to wait from item ${future} to finish")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment