diff --git a/lib/ansible/modules/web_infrastructure/jenkins_plugin.py b/lib/ansible/modules/web_infrastructure/jenkins_plugin.py index 56067c38a60..832dbe060aa 100644 --- a/lib/ansible/modules/web_infrastructure/jenkins_plugin.py +++ b/lib/ansible/modules/web_infrastructure/jenkins_plugin.py @@ -442,6 +442,13 @@ class JenkinsPlugin(object): msg_exception="Plugin installation has failed.", data=data) + hpi_file = '%s/plugins/%s.hpi' % ( + self.params['jenkins_home'], + self.params['name']) + + if os.path.isfile(hpi_file): + os.remove(hpi_file) + changed = True else: # Check if the plugin directory exists @@ -567,7 +574,7 @@ class JenkinsPlugin(object): msg_exception="Updates download failed.") # Write the updates file - updates_file = tempfile.mkstemp() + update_fd, updates_file = tempfile.mkstemp() try: fd = open(updates_file, 'wb') @@ -644,7 +651,7 @@ class JenkinsPlugin(object): def _write_file(self, f, data): # Store the plugin into a temp file and then move it - tmp_f = tempfile.mkstemp() + tmp_f_tuple, tmp_f = tempfile.mkstemp() try: fd = open(tmp_f, 'wb')