pipeline {
    agent any
	tools {
		maven 'Default'
		jdk 'java-11-openjdk-amd64'
	}

    stages {
		stage('Initialize') {
            steps {
			sh '''
				echo "PATH = ${PATH}"
				echo "M2_HOME = ${M2_HOME}"
			'''
            }
        }
        stage('Build') {
            steps {
                echo 'Building...'
				sh '''
				cd BackEnd
				mvn clean install -Dmaven.test.skip=true
				sh '''
            }
        }
        stage('Test') {
            steps {
                echo 'Testing...'
            }
        }
        stage('Deploy') {
            steps {
                echo 'Deploying...'
            }
        }
        stage('Front-end') {
            agent {
                dockerfile true
            }
            environment {
                HOME = '.'
            }
            steps {
                echo 'Building FrontEnd...'
                sh '''
                    [ ! -d "Punktonerzy" ] && git clone https://git.wmi.amu.edu.pl/s416178/Punktonerzy.git
                    cd Punktonerzy
                    git pull
                    cd FrontEnd
                    npm install
                    npm run mybuild
				'''
            }
        }
    }
}