Compare commits
4 Commits
fix/cl9-no
...
fix/cl9-us
| Author | SHA1 | Date | |
|---|---|---|---|
| 164e97618e | |||
| 2bb78e9864 | |||
| 173071cd5c | |||
| fc73bf422f |
36
Jenkinsfile
vendored
36
Jenkinsfile
vendored
@@ -85,33 +85,36 @@ pipeline {
|
|||||||
|
|
||||||
stage('Deploy') {
|
stage('Deploy') {
|
||||||
steps {
|
steps {
|
||||||
withCredentials([sshUserPrivateKey(
|
|
||||||
credentialsId: "${env.DEPLOY_SSH_CREDENTIAL_ID}",
|
|
||||||
keyFileVariable: 'SSH_KEY'
|
|
||||||
)]) {
|
|
||||||
sh '''
|
sh '''
|
||||||
bash <<EOF
|
bash <<EOF
|
||||||
set -euxo pipefail
|
set -euxo pipefail
|
||||||
|
|
||||||
|
SSH_KEY="/var/lib/jenkins/.ssh/plesk_agency_deploy"
|
||||||
|
SSH_USER="deploy"
|
||||||
SSH_OPTS="-i ${SSH_KEY} -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
SSH_OPTS="-i ${SSH_KEY} -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
||||||
|
|
||||||
|
echo "SSH user from configured deploy key: ${SSH_USER}"
|
||||||
|
echo "SSH key file path: ${SSH_KEY}"
|
||||||
|
ls -l "${SSH_KEY}"
|
||||||
|
ssh-keygen -y -f "${SSH_KEY}"
|
||||||
|
|
||||||
echo "Testing remote SSH connectivity"
|
echo "Testing remote SSH connectivity"
|
||||||
ssh ${SSH_OPTS} "${APP_USER}@${APP_HOST}" "whoami && hostname && pwd"
|
ssh ${SSH_OPTS} "${SSH_USER}@${APP_HOST}" "whoami && hostname && pwd"
|
||||||
|
|
||||||
echo "Deploying image tag: ${IMAGE_BUILD}"
|
echo "Deploying image tag: ${IMAGE_BUILD}"
|
||||||
docker image inspect "${IMAGE_BUILD}" --format='{{.Id}} {{.RepoTags}}'
|
docker image inspect "${IMAGE_BUILD}" --format='{{.Id}} {{.RepoTags}}'
|
||||||
|
|
||||||
ssh ${SSH_OPTS} "$APP_USER@$APP_HOST" "mkdir -p $DEPLOY_PATH/scripts"
|
ssh ${SSH_OPTS} "$SSH_USER@$APP_HOST" "mkdir -p $DEPLOY_PATH/scripts"
|
||||||
|
|
||||||
rsync -az \
|
rsync -az \
|
||||||
-e "ssh ${SSH_OPTS}" \
|
-e "ssh ${SSH_OPTS}" \
|
||||||
docker-compose.prod.yml \
|
docker-compose.prod.yml \
|
||||||
"$APP_USER@$APP_HOST:$DEPLOY_PATH/"
|
"$SSH_USER@$APP_HOST:$DEPLOY_PATH/"
|
||||||
|
|
||||||
rsync -az \
|
rsync -az \
|
||||||
-e "ssh ${SSH_OPTS}" \
|
-e "ssh ${SSH_OPTS}" \
|
||||||
scripts/ \
|
scripts/ \
|
||||||
"$APP_USER@$APP_HOST:$DEPLOY_PATH/scripts/"
|
"$SSH_USER@$APP_HOST:$DEPLOY_PATH/scripts/"
|
||||||
|
|
||||||
IMAGE_TAR="plesk-agency-portal-build.tar"
|
IMAGE_TAR="plesk-agency-portal-build.tar"
|
||||||
echo "Creating image archive: ${IMAGE_TAR}"
|
echo "Creating image archive: ${IMAGE_TAR}"
|
||||||
@@ -120,31 +123,30 @@ ls -lh "${IMAGE_TAR}"
|
|||||||
sha256sum "${IMAGE_TAR}"
|
sha256sum "${IMAGE_TAR}"
|
||||||
|
|
||||||
echo "Copying image archive to remote host via scp"
|
echo "Copying image archive to remote host via scp"
|
||||||
scp ${SSH_OPTS} "${IMAGE_TAR}" "$APP_USER@$APP_HOST:$DEPLOY_PATH/"
|
scp ${SSH_OPTS} "${IMAGE_TAR}" "$SSH_USER@$APP_HOST:$DEPLOY_PATH/"
|
||||||
|
|
||||||
echo "Verifying image archive exists on remote host"
|
echo "Verifying image archive exists on remote host"
|
||||||
ssh ${SSH_OPTS} "$APP_USER@$APP_HOST" "ls -lh $DEPLOY_PATH/plesk-agency-portal-build.tar"
|
ssh ${SSH_OPTS} "$SSH_USER@$APP_HOST" "ls -lh $DEPLOY_PATH/plesk-agency-portal-build.tar"
|
||||||
ssh ${SSH_OPTS} "$APP_USER@$APP_HOST" "sha256sum $DEPLOY_PATH/plesk-agency-portal-build.tar"
|
ssh ${SSH_OPTS} "$SSH_USER@$APP_HOST" "sha256sum $DEPLOY_PATH/plesk-agency-portal-build.tar"
|
||||||
|
|
||||||
echo "Loading image archive on remote host"
|
echo "Loading image archive on remote host"
|
||||||
ssh ${SSH_OPTS} "$APP_USER@$APP_HOST" "docker load -i $DEPLOY_PATH/plesk-agency-portal-build.tar"
|
ssh ${SSH_OPTS} "$SSH_USER@$APP_HOST" "docker load -i $DEPLOY_PATH/plesk-agency-portal-build.tar"
|
||||||
|
|
||||||
echo "Verifying exact image tag is available on remote host"
|
echo "Verifying exact image tag is available on remote host"
|
||||||
ssh ${SSH_OPTS} "$APP_USER@$APP_HOST" "docker image inspect ${IMAGE_BUILD} --format='{{.Id}} {{.RepoTags}}'"
|
ssh ${SSH_OPTS} "$SSH_USER@$APP_HOST" "docker image inspect ${IMAGE_BUILD} --format='{{.Id}} {{.RepoTags}}'"
|
||||||
|
|
||||||
ssh ${SSH_OPTS} "$APP_USER@$APP_HOST" \
|
ssh ${SSH_OPTS} "$SSH_USER@$APP_HOST" \
|
||||||
"cd $DEPLOY_PATH && chmod +x ./scripts/deploy-prod.sh ./scripts/smoke-check.sh ./scripts/rollback-prod.sh"
|
"cd $DEPLOY_PATH && chmod +x ./scripts/deploy-prod.sh ./scripts/smoke-check.sh ./scripts/rollback-prod.sh"
|
||||||
|
|
||||||
echo "Running remote deploy script with exact image tag"
|
echo "Running remote deploy script with exact image tag"
|
||||||
ssh ${SSH_OPTS} "$APP_USER@$APP_HOST" \
|
ssh ${SSH_OPTS} "$SSH_USER@$APP_HOST" \
|
||||||
"cd $DEPLOY_PATH && APP_IMAGE='${IMAGE_BUILD}' ./scripts/deploy-prod.sh"
|
"cd $DEPLOY_PATH && APP_IMAGE='${IMAGE_BUILD}' ./scripts/deploy-prod.sh"
|
||||||
|
|
||||||
echo "Printing final running container image metadata"
|
echo "Printing final running container image metadata"
|
||||||
ssh ${SSH_OPTS} "$APP_USER@$APP_HOST" "docker inspect plesk-agency-portal --format='{{.Image}} {{.Created}}'"
|
ssh ${SSH_OPTS} "$SSH_USER@$APP_HOST" "docker inspect plesk-agency-portal --format='{{.Image}} {{.Created}}'"
|
||||||
EOF
|
EOF
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Smoke check') {
|
stage('Smoke check') {
|
||||||
|
|||||||
Reference in New Issue
Block a user