Compare commits
8 Commits
fix/cl9-je
...
fix/cl9-je
| Author | SHA1 | Date | |
|---|---|---|---|
| 0e2dd1bfc7 | |||
| 99f020f560 | |||
| 4d241545d2 | |||
| 2e8849332b | |||
| d30a7d37b5 | |||
| 6a09053ac3 | |||
| ab27e57e66 | |||
| cd4ba09404 |
52
Jenkinsfile
vendored
52
Jenkinsfile
vendored
@@ -1,8 +1,3 @@
|
||||
def DEPLOY_SSH_CREDENTIAL_ID = env.DEPLOY_SSH_CREDENTIAL_ID ?: 'plesk-agency-deploy-key'
|
||||
def APP_HOST = env.APP_HOST ?: '192.168.68.89'
|
||||
def APP_USER = env.APP_USER ?: 'deploy'
|
||||
def DEPLOY_PATH = env.DEPLOY_PATH ?: '/opt/plesk-agency-portal'
|
||||
|
||||
pipeline {
|
||||
// Build + deploy stages require Docker CLI/daemon access on the Jenkins node.
|
||||
// Ensure this label maps to an agent with Docker installed and usable.
|
||||
@@ -12,6 +7,12 @@ pipeline {
|
||||
REGISTRY_IMAGE = "plesk-agency-portal"
|
||||
IMAGE_LATEST = "${REGISTRY_IMAGE}:latest"
|
||||
IMAGE_BUILD = "${REGISTRY_IMAGE}:build-${BUILD_NUMBER}"
|
||||
DEPLOY_SSH_CREDENTIAL_ID = "${env.DEPLOY_SSH_CREDENTIAL_ID ?: 'plesk-agency-deploy-key'}"
|
||||
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 ?: 'http://192.168.68.89:3000'}"
|
||||
|
||||
}
|
||||
|
||||
stages {
|
||||
@@ -71,36 +72,51 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy') {
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
withCredentials([sshUserPrivateKey(
|
||||
credentialsId: DEPLOY_SSH_CREDENTIAL_ID,
|
||||
credentialsId: "${env.DEPLOY_SSH_CREDENTIAL_ID}",
|
||||
keyFileVariable: 'SSH_KEY'
|
||||
)]) {
|
||||
sh '''
|
||||
set -euo pipefail
|
||||
bash -eo pipefail << 'EOF'
|
||||
set -euo pipefail
|
||||
|
||||
rsync -az \
|
||||
docker-compose.prod.yml \
|
||||
scripts/ \
|
||||
ssh -i "$SSH_KEY" "$APP_USER@$APP_HOST" "mkdir -p $DEPLOY_PATH/scripts"
|
||||
|
||||
rsync -az \
|
||||
-e "ssh -i $SSH_KEY" \
|
||||
$APP_USER@$APP_HOST:$DEPLOY_PATH/
|
||||
docker-compose.prod.yml \
|
||||
"$APP_USER@$APP_HOST:$DEPLOY_PATH/"
|
||||
|
||||
docker save ${IMAGE_LATEST} ${IMAGE_BUILD} \
|
||||
| ssh -i $SSH_KEY $APP_USER@$APP_HOST 'docker load'
|
||||
rsync -az \
|
||||
-e "ssh -i $SSH_KEY" \
|
||||
scripts/ \
|
||||
"$APP_USER@$APP_HOST:$DEPLOY_PATH/scripts/"
|
||||
|
||||
ssh -i $SSH_KEY $APP_USER@$APP_HOST \
|
||||
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"
|
||||
ssh -i "$SSH_KEY" "$APP_USER@$APP_HOST" \
|
||||
"cd $DEPLOY_PATH && ./scripts/deploy-prod.sh"
|
||||
EOF
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Smoke check') {
|
||||
steps {
|
||||
sh 'chmod +x scripts/smoke-check.sh && scripts/smoke-check.sh ${APP_BASE_URL}'
|
||||
sh '''
|
||||
bash -eo pipefail << EOF
|
||||
set -euo pipefail
|
||||
chmod +x scripts/smoke-check.sh
|
||||
scripts/smoke-check.sh "${APP_BASE_URL}"
|
||||
EOF
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user