mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
jenkins_plugin: avoid undefined variable when updates file is not downloaded (#6100)
Avoid undefined variable when updates file is not downloaded.
This commit is contained in:
parent
29f5033737
commit
e8bdec2733
2 changed files with 7 additions and 3 deletions
2
changelogs/fragments/6100-jenkins_plugin.yml
Normal file
2
changelogs/fragments/6100-jenkins_plugin.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- "jenkins_plugin - fix error due to undefined variable when updates file is not downloaded (https://github.com/ansible-collections/community.general/pull/6100)."
|
|
@ -641,6 +641,8 @@ class JenkinsPlugin(object):
|
|||
self.module.fail_json(
|
||||
msg="Cannot close the tmp updates file %s." % tmp_updates_file,
|
||||
details=to_native(e))
|
||||
else:
|
||||
tmp_updates_file = updates_file
|
||||
|
||||
# Open the updates file
|
||||
try:
|
||||
|
@ -651,15 +653,15 @@ class JenkinsPlugin(object):
|
|||
data = json.loads(f.readline())
|
||||
except IOError as e:
|
||||
self.module.fail_json(
|
||||
msg="Cannot open temporal updates file.",
|
||||
msg="Cannot open%s updates file." % (" temporary" if tmp_updates_file != updates_file else ""),
|
||||
details=to_native(e))
|
||||
except Exception as e:
|
||||
self.module.fail_json(
|
||||
msg="Cannot load JSON data from the tmp updates file.",
|
||||
msg="Cannot load JSON data from the%s updates file." % (" temporary" if tmp_updates_file != updates_file else ""),
|
||||
details=to_native(e))
|
||||
|
||||
# Move the updates file to the right place if we could read it
|
||||
if download_updates:
|
||||
if tmp_updates_file != updates_file:
|
||||
self.module.atomic_move(tmp_updates_file, updates_file)
|
||||
|
||||
# Check if we have the plugin data available
|
||||
|
|
Loading…
Reference in a new issue