add branch validation to queue

This commit is contained in:
2025-12-22 14:45:39 +01:00
parent 9cefb24193
commit 613b494e1d
3 changed files with 20 additions and 7 deletions

View File

@@ -24,17 +24,23 @@ def debug_ssh_test():
ssh_password = os.environ.get('SSH_PASSWORD', 'default_password')
ssh_host = os.environ.get('SSH_HOST', 'remote_host')
ssh_user = os.environ.get('SSH_USER', 'asf')
ssh_port = os.environ.get('SSH_PORT', '22')
# SSH options for better connectivity
ssh_options = f"-p {ssh_port} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
# Test basic SSH connectivity
test_cmd = f"sshpass -p '{ssh_password}' ssh -o StrictHostKeyChecking=no {ssh_user}@{ssh_host} 'echo SSH_CONNECTION_SUCCESS'"
test_cmd = f"sshpass -p '{ssh_password}' ssh {ssh_options} {ssh_user}@{ssh_host} 'echo SSH_CONNECTION_SUCCESS'"
result = subprocess.run(test_cmd, shell=True, capture_output=True, text=True, timeout=30)
return jsonify({
'ssh_config': {
'user': ssh_user,
'host': ssh_host,
'port': ssh_port,
'password_set': bool(ssh_password and ssh_password != 'default_password')
},
'command_executed': test_cmd.replace(ssh_password, '***'),
'test_result': {
'returncode': result.returncode,
'stdout': result.stdout,
@@ -67,12 +73,16 @@ def submit_step1():
ssh_password = os.environ.get('SSH_PASSWORD', 'default_password')
ssh_host = os.environ.get('SSH_HOST', 'remote_host')
ssh_user = os.environ.get('SSH_USER', 'asf')
ssh_port = os.environ.get('SSH_PORT', '22')
print(f"[DEBUG] Starting branch validation for: {branch_name}")
print(f"[DEBUG] SSH Config - User: {ssh_user}, Host: {ssh_host}")
print(f"[DEBUG] SSH Config - User: {ssh_user}, Host: {ssh_host}, Port: {ssh_port}")
# SSH options for better connectivity
ssh_options = f"-p {ssh_port} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
# First, clone the repository
clone_cmd = f"sshpass -p '{ssh_password}' ssh -o StrictHostKeyChecking=no {ssh_user}@{ssh_host} './TPF/gitea_repo_controller.sh clone'"
clone_cmd = f"sshpass -p '{ssh_password}' ssh {ssh_options} {ssh_user}@{ssh_host} './TPF/gitea_repo_controller.sh clone'"
print(f"[DEBUG] Executing clone command: {clone_cmd.replace(ssh_password, '***')}")
clone_result = subprocess.run(clone_cmd, shell=True, capture_output=True, text=True, timeout=60)
@@ -82,7 +92,7 @@ def submit_step1():
print(f"[DEBUG] Clone stderr: {clone_result.stderr}")
# Then, checkout the branch
checkout_cmd = f"sshpass -p '{ssh_password}' ssh -o StrictHostKeyChecking=no {ssh_user}@{ssh_host} './TPF/gitea_repo_controller.sh checkout {branch_name}'"
checkout_cmd = f"sshpass -p '{ssh_password}' ssh {ssh_options} {ssh_user}@{ssh_host} './TPF/gitea_repo_controller.sh checkout {branch_name}'"
print(f"[DEBUG] Executing checkout command: {checkout_cmd.replace(ssh_password, '***')}")
checkout_result = subprocess.run(checkout_cmd, shell=True, capture_output=True, text=True, timeout=60)