diff --git a/Jenkinsfile b/Jenkinsfile index 4c969a9..be62b5d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -59,18 +59,20 @@ stage('Update Repo on Remote') { if [ -d ${REMOTE_DIR}/certificates ]; then cp -a ${REMOTE_DIR}/certificates ${BACKUP_UPLOADS_DIR}/ fi - - # Pull or clone repo + + # Pull latest changes without deleting local files/folders if [ -d ${REMOTE_DIR}/.git ]; then echo "🔁 Repo exists. Pulling latest changes..." cd ${REMOTE_DIR} - git reset --hard - git clean -fd + git stash push --include-untracked --message "temp-backup-before-pull" || true git pull origin ${BRANCH} + git stash pop || true else echo "📥 Repo not found. Cloning fresh and restoring backup..." rm -rf ${REMOTE_DIR} - git clone -b ${BRANCH} https://${GIT_USER}:${GIT_PASS}@https://git.tech4biz.wiki/rohit/spurrin-backend.git ${REMOTE_DIR} + git clone -b ${BRANCH} https://${GIT_USER}:${GIT_PASS}@git.tech4biz.wiki/rohit/spurrin-backend.git ${REMOTE_DIR} + + # Restore backups only on fresh clone... # Restore backup only on fresh clone if [ -d ${BACKUP_UPLOADS_DIR}/uploads ]; then