From 4d241545d2b3d5f7692d924dca6d993635002c0b Mon Sep 17 00:00:00 2001 From: robbond Date: Fri, 6 Mar 2026 17:56:46 +0000 Subject: [PATCH] update deploy stage and smoke check for scripts --- Jenkinsfile | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3b7d794..3a95083 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,6 +11,8 @@ pipeline { APP_HOST = "${env.APP_HOST ?: '192.168.68.89'}" APP_USER = "${env.APP_USER ?: 'deploy'}" DEPLOY_PATH = "${env.DEPLOY_PATH ?: '/opt/plesk-agency-portal'}" + APP_BASE_URL = "${env.APP_BASE_URL ?: 'https://portal.rdbcloud.co.uk}" + } stages { @@ -70,34 +72,41 @@ pipeline { } } - stage('Deploy') { - steps { - withCredentials([sshUserPrivateKey( - credentialsId: "${env.DEPLOY_SSH_CREDENTIAL_ID}", - keyFileVariable: 'SSH_KEY' - )]) { - sh ''' +stage('Deploy') { + steps { + withCredentials([sshUserPrivateKey( + credentialsId: "${env.DEPLOY_SSH_CREDENTIAL_ID}", + keyFileVariable: 'SSH_KEY' + )]) { + sh ''' bash -eo pipefail << 'EOF' - set -euo pipefail +set -euo pipefail - rsync -az \ - docker-compose.prod.yml \ - scripts/ \ - -e "ssh -i $SSH_KEY" \ - $APP_USER@$APP_HOST:$DEPLOY_PATH/ +ssh -i "$SSH_KEY" "$APP_USER@$APP_HOST" "mkdir -p $DEPLOY_PATH/scripts" - docker save ${IMAGE_LATEST} ${IMAGE_BUILD} \ - | ssh -i $SSH_KEY $APP_USER@$APP_HOST 'docker load' +rsync -az \ + -e "ssh -i $SSH_KEY" \ + docker-compose.prod.yml \ + "$APP_USER@$APP_HOST:$DEPLOY_PATH/" - ssh -i $SSH_KEY $APP_USER@$APP_HOST \ - "cd $DEPLOY_PATH && chmod +x ./scripts/deploy-prod.sh ./scripts/smoke-check.sh ./scripts/rollback-prod.sh" +rsync -az \ + -e "ssh -i $SSH_KEY" \ + scripts/ \ + "$APP_USER@$APP_HOST:$DEPLOY_PATH/scripts/" - ssh -i $SSH_KEY $APP_USER@$APP_HOST "cd $DEPLOY_PATH && ./scripts/deploy-prod.sh" +docker save ${IMAGE_LATEST} ${IMAGE_BUILD} \ + | ssh -i "$SSH_KEY" "$APP_USER@$APP_HOST" 'docker load' + +ssh -i "$SSH_KEY" "$APP_USER@$APP_HOST" \ + "cd $DEPLOY_PATH && chmod +x ./scripts/deploy-prod.sh ./scripts/smoke-check.sh ./scripts/rollback-prod.sh" + +ssh -i "$SSH_KEY" "$APP_USER@$APP_HOST" \ + "cd $DEPLOY_PATH && ./scripts/deploy-prod.sh" EOF - ''' - } - } + ''' } + } +} stage('Smoke check') { steps { -- 2.39.5