#!/usr/bin/env groovy

pipeline {
    agent { label 'prod' }
    stages {
        stage('Check env') {
            steps {
                echo "Displaying Jenkins environment variables ..."
                echo "BRANCH_NAME : ${env.BRANCH_NAME}"
                echo "JOVIAN_WEB_DEPLOY_PATH : ${env.JOVIAN_WEB_DEPLOY_PATH}"
                echo "JOVIAN_WEB_PREPROD_PATH : ${env.JOVIAN_WEB_PREPROD_PATH}"
                echo "Done."
            }
        }
        stage('Deploy') {
            when { branch 'master' }
            steps {
                sh "undeployed/scripts/deploy/up-date.sh"
                sh "undeployed/scripts/deploy/up-version.sh"
                sh "rsync --delete --recursive --verbose web/ ${env.JOVIAN_WEB_DEPLOY_PATH}"
            }
        }
    }
}
