Improve delete all job performance
delete-all command was deleting one job at a time using the jenkins doDelete rest endpoint which is very slow. Change Ia4fbfca970165 allows us to execute a groovy script on the jenkins server to do the same thing. The only difference is that running the script on the server will delete all jobs much faster. As a data point: I added all (~5,000) openstack jobs to my jenkins server. The previous delete_all took many hours to delete all the jobs while the script method did it in a matter of seconds. Change-Id: Id7f7dfb567997e042fe0f783e54680482fefdc15 depends-on: Ia4fbfca970165d890d7e076f47ddcde7633afa9b
This commit is contained in:
parent
78e7e38533
commit
67de07ceed
@ -142,6 +142,13 @@ class Jenkins(object):
|
||||
logger.info("Deleting jenkins job {0}".format(job_name))
|
||||
self.jenkins.delete_job(job_name)
|
||||
|
||||
def delete_all_jobs(self):
|
||||
# execute a groovy script to delete all jobs is much faster than
|
||||
# using the doDelete REST endpoint to delete one job at a time.
|
||||
script = ('for(job in jenkins.model.Jenkins.theInstance.getProjects())'
|
||||
' { job.delete(); }')
|
||||
self.jenkins.run_script(script)
|
||||
|
||||
def get_plugins_info(self):
|
||||
""" Return a list of plugin_info dicts, one for each plugin on the
|
||||
Jenkins instance.
|
||||
@ -275,8 +282,7 @@ class Builder(object):
|
||||
def delete_all_jobs(self):
|
||||
jobs = self.jenkins.get_jobs()
|
||||
logger.info("Number of jobs to delete: %d", len(jobs))
|
||||
for job in jobs:
|
||||
self.delete_job(job['name'])
|
||||
self.jenkins.delete_all_jobs()
|
||||
|
||||
def update_job(self, input_fn, jobs_glob=None, output=None):
|
||||
self.load_files(input_fn)
|
||||
|
@ -2,5 +2,5 @@ argparse
|
||||
ordereddict
|
||||
six>=1.5.2
|
||||
PyYAML
|
||||
python-jenkins>=0.4.1
|
||||
python-jenkins>=0.4.8
|
||||
pbr>=0.8.2,<2.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user