//this is if we pass personnal credentials for a particualr repo
pipeline {
    agent any

    environment {
        REMOTE_DIR = '/var/www/html/demo'
        GIT_REPO = 'functions-of-blood-ps06'
        OUTPUT_URL = 'http://jenkins.swechaap.org/demo/'
    }

    stages {
        stage('Checkout') {
            steps {
                git branch: 'main', url: 'https://code.swecha.org/swecha-ap-internships/balaswecha-simulation-2024/functions-of-blood-ps06.git'
            }
        }
//deploy stage
        stage('Deploy') {
            steps {
                
               //To copy your project files to a folder
                //sh "cp index.html images ${REMOTE_DIR}/${GIT_REPO}/ -r"
                sh "rsync -av --exclude='.git' ./ ${REMOTE_DIR}/${GIT_REPO}/ -r"

            }
        }
    }
//end
    post {
        success {
            echo "Visit the following URL to see your project output : ${env.OUTPUT_URL}${env.GIT_REPO}"
            echo 'Deployment successful.'
        }
        failure {
            echo 'Deployment failed.'
        }
    }
}
