mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[PR #6100/e8bdec27 backport][stable-6] jenkins_plugin: avoid undefined variable when updates file is not downloaded (#6103)
jenkins_plugin: avoid undefined variable when updates file is not downloaded (#6100)
Avoid undefined variable when updates file is not downloaded.
(cherry picked from commit e8bdec2733
)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
eb6ef5ae2e
commit
90a1743acf
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(
|
self.module.fail_json(
|
||||||
msg="Cannot close the tmp updates file %s." % tmp_updates_file,
|
msg="Cannot close the tmp updates file %s." % tmp_updates_file,
|
||||||
details=to_native(e))
|
details=to_native(e))
|
||||||
|
else:
|
||||||
|
tmp_updates_file = updates_file
|
||||||
|
|
||||||
# Open the updates file
|
# Open the updates file
|
||||||
try:
|
try:
|
||||||
|
@ -651,15 +653,15 @@ class JenkinsPlugin(object):
|
||||||
data = json.loads(f.readline())
|
data = json.loads(f.readline())
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
self.module.fail_json(
|
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))
|
details=to_native(e))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.module.fail_json(
|
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))
|
details=to_native(e))
|
||||||
|
|
||||||
# Move the updates file to the right place if we could read it
|
# 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)
|
self.module.atomic_move(tmp_updates_file, updates_file)
|
||||||
|
|
||||||
# Check if we have the plugin data available
|
# Check if we have the plugin data available
|
||||||
|
|
Loading…
Reference in a new issue