pipeline {
    agent {
        docker {
            image 'mhart/alpine-node:latest'
            args '-p 3000:3000'
        }
        //  dockerfile true 
    }
    environment {
        CI = 'true'
    }
    stages {
        stage('Prepare') {
            steps {
                // withEnv(['PATH+NODE=/usr/local/bin/node']) {
                // echo 'Prepare step started ... '
                // sh 'echo prefix = ~/.node >> ~/.npmrc'
                // sh 'whoami'
                // sh 'chown -R node:node /usr/local/lib/node_modules'
                sh 'cd /var/jenkins_home/workspace/tt-app_app_Saga/nextjs/'
                sh 'yarn install'
                // }
            }
        }
        stage('Build') {
            steps {
                echo 'Build step started ... '
                sh '/var/jenkins_home/workspace/tt-app_app_Saga/nextjs/scripts/start.sh'
            }
        }
        stage('Test') {
            steps {
                sh '/var/jenkins_home/workspace/tt-app_app_Saga/nextjs/scripts/test.sh'
            }
        }
        stage('Response') {
            steps {
                echo 'Vous pouvez pull sur la production'
                sh '/var/jenkins_home/workspace/tt-app_app_Saga/nextjs/scripts/kill.sh'
            }
        }
    }
}