1
0
Fork 0
mirror of https://github.com/sbrl/powahroot.git synced 2024-11-25 15:43:00 +00:00

We do care about the status of sftp

This commit is contained in:
Starbeamrainbowlabs 2019-04-28 17:29:37 +01:00
parent 8bb8986432
commit bf75e22b06
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

17
build
View file

@ -120,23 +120,19 @@ task_deploy() {
stage_end 1; stage_end 1;
fi fi
task_begin "Preparing upload"; task_begin "Preparing upload";
subtask_begin "Unwinding symlinks"; subtask_begin "Unwinding symlinks";
find "${docs_output_folder}" -type l -exec bash -c 'ln -f "$(readlink -m "$0")" "$0"' {} \; find "${docs_output_folder}" -type l -exec bash -c 'ln -f "$(readlink -m "$0")" "$0"' {} \;
subtask_end $?; subtask_end $?;
task_end $?; task_end $?;
task_begin "Uploading Release";
# Acquire an exclusive project-wide lock so that we only upload stuff one-at-a-time # Acquire an exclusive project-wide lock so that we only upload stuff one-at-a-time
subtask_begin "Acquiring upload lock"; task_begin "Acquiring upload lock";
exec 9<"${WORKSPACE}"; exec 9<"${WORKSPACE}";
flock --exclusive 9; flock --exclusive 9;
subtask_end $? "Failed to acquire lock!"; task_end $? "Failed to acquire lock!";
task_begin "Cleaning up old release";
lftp_commands_filename="$(mktemp --suffix "-commands.lftp")"; lftp_commands_filename="$(mktemp --suffix "-commands.lftp")";
( (
echo "set sftp:connect-program 'ssh -x -i ${SSH_KEY_PATH}'"; echo "set sftp:connect-program 'ssh -x -i ${SSH_KEY_PATH}'";
@ -149,21 +145,20 @@ task_deploy() {
execute lftp --version; execute lftp --version;
execute cat "${lftp_commands_filename}"; execute cat "${lftp_commands_filename}";
execute lftp -f "${lftp_commands_filename}"; execute lftp -f "${lftp_commands_filename}";
exit_code=$? task_end $? "Failed to cleanup old release";
task_begin "Uploading new release";
sftp -i "${SSH_KEY_PATH}" -P "${deploy_ssh_port}" -o PasswordAuthentication=no "${deploy_ssh_user}@${deploy_ssh_host}" << SFTPCOMMANDS sftp -i "${SSH_KEY_PATH}" -P "${deploy_ssh_port}" -o PasswordAuthentication=no "${deploy_ssh_user}@${deploy_ssh_host}" << SFTPCOMMANDS
mkdir ${deploy_root_dir}/docs mkdir ${deploy_root_dir}/docs
put -r ${docs_output_folder}/* ${deploy_root_dir}/docs/ put -r ${docs_output_folder}/* ${deploy_root_dir}/docs/
bye bye
SFTPCOMMANDS SFTPCOMMANDS
task_end $? "Failed to upload new release";
subtask_begin "Releasing lock"; subtask_begin "Releasing lock";
exec 9>&- # Close file descriptor 9 and release the lock exec 9>&- # Close file descriptor 9 and release the lock
subtask_end $?; subtask_end $?;
task_end "${exit_code}" "Failed to upload release";
stage_end $? "Failed to deploy to ${deploy_ssh_host}."; stage_end $? "Failed to deploy to ${deploy_ssh_host}.";
} }