mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-21 20:30:21 -07:00
Fix a logical flaw when deleting a build in the jenkins_build module (#5514)
* Fix the logical flaw when deleting a build in the jenkins_build module. * Fix the logical flaw when deleting a Jenkins build in the jenkins_build module. * Adding changelogs. * Update tests/unit/plugins/modules/test_jenkins_build.py Co-authored-by: Felix Fontein <felix@fontein.de> * Attempt to mock the exception classes. * Remedy the CI issues when mocking the exception classes. * Assuming a way to mock the get_build_status function. * Near to the feasible approach. * Calls the correct class when unit testing. * Fix sending wrong arguments when unit testing. * Directly assign the argument value in the unit testing. * Fix errors calling different classes. Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
6b20572ea1
commit
7610501c66
3 changed files with 55 additions and 5 deletions
|
@ -183,7 +183,10 @@ class JenkinsBuild:
|
|||
try:
|
||||
response = self.server.get_build_info(self.name, self.build_number)
|
||||
return response
|
||||
|
||||
except jenkins.JenkinsException as e:
|
||||
response = {}
|
||||
response["result"] = "ABSENT"
|
||||
return response
|
||||
except Exception as e:
|
||||
self.module.fail_json(msg='Unable to fetch build information, %s' % to_native(e),
|
||||
exception=traceback.format_exc())
|
||||
|
@ -231,7 +234,10 @@ class JenkinsBuild:
|
|||
if self.state == "stopped" and build_status['result'] == "ABORTED":
|
||||
result['changed'] = True
|
||||
result['build_info'] = build_status
|
||||
elif build_status['result'] == "SUCCESS":
|
||||
elif self.state == "absent" and build_status['result'] == "ABSENT":
|
||||
result['changed'] = True
|
||||
result['build_info'] = build_status
|
||||
elif self.state != "absent" and build_status['result'] == "SUCCESS":
|
||||
result['changed'] = True
|
||||
result['build_info'] = build_status
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue