pipeline {
    agent {
        docker { 
            image 'kargor8/sess-comp-base:v2'
        }
    }
    environment {
        DOTNET_CLI_HOME = '/tmp/App'
    }
    stages {
        stage('Build app') {
            steps {
                dir('SessionCompanion') {
                    sh "echo $USER"
                    withEnv(["HOME=${env.WORKSPACE}"]){
                        dir ('SessionCompanion/ClientApp') {
                            sh 'npm cache clean --force'
                            sh 'npm install'
                        }
                        sh 'dotnet build'
                    }
                }
            }
        }
        stage('Clear') {
            steps  {
                withEnv(["HOME=${env.WORKSPACE}"]){
                    sh 'rm -rf .local'
                }
            }
        }
    }
}