From: Aleksey Maksimov Date: Sat, 12 Apr 2014 16:48:05 +0000 (+0800) Subject: Added re-try when removing job X-Git-Tag: v0.2.23~24^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad154c8346731c642efac75c941b249b0d2313f2;p=tools%2Fpython-jenkinsapi.git Added re-try when removing job Becuase Jenkins sometimes breaks for unknown reason while removing jobs --- diff --git a/jenkinsapi/jobs.py b/jenkinsapi/jobs.py index de87a79..91a7382 100644 --- a/jenkinsapi/jobs.py +++ b/jenkinsapi/jobs.py @@ -29,11 +29,24 @@ class Jobs(object): :param job_name: name of a exist job, str """ if job_name in self: - delete_job_url = self[job_name].get_delete_url() - self.jenkins.requester.post_and_confirm_status( - delete_job_url, - data='some random bytes...' - ) + try: + delete_job_url = self[job_name].get_delete_url() + self.jenkins.requester.post_and_confirm_status( + delete_job_url, + data='some random bytes...' + ) + except JenkinsAPIException: + # Sometimes jenkins throws NPE when removing job + # It removes job ok, but it is good to be sure + # so we re-try if job was not deleted + self.jenkins.poll() + if job_name in self: + delete_job_url = self[job_name].get_delete_url() + self.jenkins.requester.post_and_confirm_status( + delete_job_url, + data='some random bytes...' + ) + self.jenkins.poll() def __setitem__(self, key, value):