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~23^2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=111d2b6422015133ebf0da6c52dc57bf0ff7d0bf;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 23f1133..eda5e7c 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):