pipeline {
    agent any
    environment {
        BRANCH_NAME="${env.BRANCH_NAME}".toLowerCase()
    }
    stages {
        stage('pullCode'){
            steps{
                echo 'This is a pullCode step'
                checkout scm
            }
        }
        stage('Build') {
            steps {
                echo 'Building..'
                sh 'docker-compose down'
                sh '~/tools/apache-maven-3.6.3/bin/mvn  clean install -Dmaven.test.skip=true'
                sh 'docker build -t ${BRANCH_NAME}:${BUILD_NUMBER} .'
            }
        }
        stage('Test') {
            steps {
                echo 'Testing..'
            }
        }
        stage('Deploy') {
            steps {
                echo 'Deploying....'
                sh 'docker-compose up -d'
            }
        }
    }
}