Compare commits
2 Commits
fix/cl9-de
...
fix/cl9-no
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c8ff2d07d | |||
| 5b5682acb1 |
27
Jenkinsfile
vendored
27
Jenkinsfile
vendored
@@ -93,18 +93,23 @@ stage('Deploy') {
|
||||
bash <<EOF
|
||||
set -euxo pipefail
|
||||
|
||||
SSH_OPTS="-i ${SSH_KEY} -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
||||
|
||||
echo "Testing remote SSH connectivity"
|
||||
ssh ${SSH_OPTS} "${APP_USER}@${APP_HOST}" "whoami && hostname && pwd"
|
||||
|
||||
echo "Deploying image tag: ${IMAGE_BUILD}"
|
||||
docker image inspect "${IMAGE_BUILD}" --format='{{.Id}} {{.RepoTags}}'
|
||||
|
||||
ssh -i "$SSH_KEY" "$APP_USER@$APP_HOST" "mkdir -p $DEPLOY_PATH/scripts"
|
||||
ssh ${SSH_OPTS} "$APP_USER@$APP_HOST" "mkdir -p $DEPLOY_PATH/scripts"
|
||||
|
||||
rsync -az \
|
||||
-e "ssh -i $SSH_KEY" \
|
||||
-e "ssh ${SSH_OPTS}" \
|
||||
docker-compose.prod.yml \
|
||||
"$APP_USER@$APP_HOST:$DEPLOY_PATH/"
|
||||
|
||||
rsync -az \
|
||||
-e "ssh -i $SSH_KEY" \
|
||||
-e "ssh ${SSH_OPTS}" \
|
||||
scripts/ \
|
||||
"$APP_USER@$APP_HOST:$DEPLOY_PATH/scripts/"
|
||||
|
||||
@@ -115,27 +120,27 @@ ls -lh "${IMAGE_TAR}"
|
||||
sha256sum "${IMAGE_TAR}"
|
||||
|
||||
echo "Copying image archive to remote host via scp"
|
||||
scp -i "$SSH_KEY" "${IMAGE_TAR}" "$APP_USER@$APP_HOST:$DEPLOY_PATH/"
|
||||
scp ${SSH_OPTS} "${IMAGE_TAR}" "$APP_USER@$APP_HOST:$DEPLOY_PATH/"
|
||||
|
||||
echo "Verifying image archive exists on remote host"
|
||||
ssh -i "$SSH_KEY" "$APP_USER@$APP_HOST" "ls -lh $DEPLOY_PATH/plesk-agency-portal-build.tar"
|
||||
ssh -i "$SSH_KEY" "$APP_USER@$APP_HOST" "sha256sum $DEPLOY_PATH/plesk-agency-portal-build.tar"
|
||||
ssh ${SSH_OPTS} "$APP_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"
|
||||
|
||||
echo "Loading image archive on remote host"
|
||||
ssh -i "$SSH_KEY" "$APP_USER@$APP_HOST" "docker load -i $DEPLOY_PATH/plesk-agency-portal-build.tar"
|
||||
ssh ${SSH_OPTS} "$APP_USER@$APP_HOST" "docker load -i $DEPLOY_PATH/plesk-agency-portal-build.tar"
|
||||
|
||||
echo "Verifying exact image tag is available on remote host"
|
||||
ssh -i "$SSH_KEY" "$APP_USER@$APP_HOST" "docker image inspect ${IMAGE_BUILD} --format='{{.Id}} {{.RepoTags}}'"
|
||||
ssh ${SSH_OPTS} "$APP_USER@$APP_HOST" "docker image inspect ${IMAGE_BUILD} --format='{{.Id}} {{.RepoTags}}'"
|
||||
|
||||
ssh -i "$SSH_KEY" "$APP_USER@$APP_HOST" \
|
||||
ssh ${SSH_OPTS} "$APP_USER@$APP_HOST" \
|
||||
"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"
|
||||
ssh -i "$SSH_KEY" "$APP_USER@$APP_HOST" \
|
||||
ssh ${SSH_OPTS} "$APP_USER@$APP_HOST" \
|
||||
"cd $DEPLOY_PATH && APP_IMAGE='${IMAGE_BUILD}' ./scripts/deploy-prod.sh"
|
||||
|
||||
echo "Printing final running container image metadata"
|
||||
ssh -i "$SSH_KEY" "$APP_USER@$APP_HOST" "docker inspect plesk-agency-portal --format='{{.Image}} {{.Created}}'"
|
||||
ssh ${SSH_OPTS} "$APP_USER@$APP_HOST" "docker inspect plesk-agency-portal --format='{{.Image}} {{.Created}}'"
|
||||
EOF
|
||||
'''
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user