mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-20 10:16:42 -06:00
Save JobResult even for a script run with commit=False
This commit is contained in:
parent
49c6bee6d7
commit
d8b0a11a49
@ -415,8 +415,6 @@ def run_script(data, request, commit=True, *args, **kwargs):
|
|||||||
try:
|
try:
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
script.output = script.run(**kwargs)
|
script.output = script.run(**kwargs)
|
||||||
job_result.data = ScriptOutputSerializer(script).data
|
|
||||||
job_result.set_status(JobResultStatusChoices.STATUS_COMPLETED)
|
|
||||||
|
|
||||||
if not commit:
|
if not commit:
|
||||||
raise AbortTransaction()
|
raise AbortTransaction()
|
||||||
@ -434,6 +432,10 @@ def run_script(data, request, commit=True, *args, **kwargs):
|
|||||||
job_result.set_status(JobResultStatusChoices.STATUS_ERRORED)
|
job_result.set_status(JobResultStatusChoices.STATUS_ERRORED)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
if job_result.status != JobResultStatusChoices.STATUS_ERRORED:
|
||||||
|
job_result.data = ScriptOutputSerializer(script).data
|
||||||
|
job_result.set_status(JobResultStatusChoices.STATUS_COMPLETED)
|
||||||
|
|
||||||
if not commit:
|
if not commit:
|
||||||
# Delete all pending changelog entries
|
# Delete all pending changelog entries
|
||||||
purge_changelog.send(Script)
|
purge_changelog.send(Script)
|
||||||
|
Loading…
Reference in New Issue
Block a user