From 6bf70b99bb380c602c97bd5dca04cabaaebe128f Mon Sep 17 00:00:00 2001 From: garciadeblas <gerardo.garciadeblas@telefonica.com> Date: Thu, 13 Mar 2025 23:58:36 +0100 Subject: [PATCH] Fix gitlab-ci.yml to exit if any step in the copy to the FTP fails Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com> --- .gitlab-ci.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 52c2eb9..00c6e36 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -56,7 +56,8 @@ publish-testing-repository: script: - apt update && apt install -y sshpass - | - echo "Uploading new files to Testing-new..." + set -e + echo "Uploading new files to temporary folder Testing-new..." sshpass -p "$VNF_CATALOG_CREDENTIALS" sftp -o "StrictHostKeyChecking no" -P $SFTP_PORT $SFTP_USER@$SFTP_SERVER << EOF mkdir Testing-new put -r vnf-catalog/* Testing-new @@ -68,9 +69,9 @@ publish-testing-repository: rename Testing-new Testing EOF - echo "Cleaning up old files..." + echo "Cleaning up temporary folder Testing-new..." sshpass -p "$VNF_CATALOG_CREDENTIALS" sftp -o "StrictHostKeyChecking no" -P $SFTP_PORT $SFTP_USER@$SFTP_SERVER << EOF - rm -rf Testing-old + rmdir Testing-new EOF rules: - if: '$CI_COMMIT_REF_NAME == "master"' # Only in master @@ -89,6 +90,7 @@ publish-ondemand-repository: script: - apt update && apt install -y sshpass - | + set -e DESTINATION_FOLDER="${ONDEMAND_DESTINATION_FOLDER:-Stable}" TEMP_FOLDER="${DESTINATION_FOLDER}-new" BACKUP_FOLDER="${DESTINATION_FOLDER}-old" @@ -105,9 +107,9 @@ publish-ondemand-repository: rename $TEMP_FOLDER $DESTINATION_FOLDER EOF - echo "Cleaning up old files..." + echo "Cleaning up temporary folder $TEMP_FOLDER..." sshpass -p "$VNF_CATALOG_CREDENTIALS" sftp -o "StrictHostKeyChecking no" -P $SFTP_PORT $SFTP_USER@$SFTP_SERVER << EOF - rm -rf $BACKUP_FOLDER + rmdir $TEMP_FOLDER EOF when: manual # This job is run on demand allow_failure: true -- GitLab