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