pipeline {
    agent any

    stages {
        stage('Build') {
            steps {
                sh 'mvn clean install -Dmaven.test.skip=true'
            }
        }

        stage('Deploy') {
            parallel {
                stage('Deploy to DEV') {
                    steps {
                        sh './ry.sh start dev'
                    }
                }
                stage('Deploy to TEST') {
                    steps {
                        sh './ry.sh start test'
                    }
                }
                stage('Deploy to PROD') {
                    steps {
                        sh './ry.sh start prod'
                    }
                }
            }
        }
    }

    post {
        always {
            archiveArtifacts artifacts: '**/*.jar', allowEmptyArchive: true
        }
        success {
            echo 'Pipeline completed successfully.'
        }
        failure {
            echo 'Pipeline failed.'
        }
    }
}