diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 5da71038a8..ee34c95604 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -65,14 +65,14 @@ class BaseTask(Task): Create a temporary file containing the SSH private key. ''' ssh_key_data = '' - if hasattr(instance, 'project'): - project = instance.project - if hasattr(project, 'scm_key_data'): - ssh_key_data = decrypt_field(project, 'scm_key_data') - elif hasattr(instance, 'credential'): + if hasattr(instance, 'credential'): credential = instance.credential if hasattr(credential, 'ssh_key_data'): ssh_key_data = decrypt_field(credential, 'ssh_key_data') + elif hasattr(instance, 'project'): + project = instance.project + if hasattr(project, 'scm_key_data'): + ssh_key_data = decrypt_field(project, 'scm_key_data') if ssh_key_data: # FIXME: File permissions? handle, path = tempfile.mkstemp()