1
0
Fork 0
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:
patchback[bot] 2023-02-26 15:52:53 +01:00 committed by GitHub
parent eb6ef5ae2e
commit 90a1743acf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View 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)."

View file

@ -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