Fix delete-all command to include all job types

getProjects() only includes simple job types like Freestyle jobs but
ignores more complex job types like Maven and Matrix jobs. This API is
also marked as deprecated in Jenkins so we probably shouldn't be using
it anyway.

Instead switch to using getAllItems() which pulls down all job types. It
is also possible to pass a parameter such as AbstractProjects or more
specific to specify exactly which job types we want to remove. In this
case though we want all of them so no need to pass any parameters.

See:
http://javadoc.jenkins-ci.org/jenkins/model/Jenkins.html

Change-Id: Ia4e37bc1d4bde70cf8f83783edd6b861eed6c2e3
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
This commit is contained in:
Thanh Ha 2016-02-03 19:22:43 -05:00
parent 75127e5f84
commit bd1c93199a
No known key found for this signature in database
GPG Key ID: B0CB27E00DA095AA
1 changed files with 1 additions and 1 deletions

View File

@ -168,7 +168,7 @@ class Jenkins(object):
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())'
script = ('for(job in jenkins.model.Jenkins.theInstance.getAllItems())'
' { job.delete(); }')
self.jenkins.run_script(script)