pipeline {
  agent any
  stages {
    stage ("install") {
      steps {
        nodejs("System NodeJS") {
          sh "npm install"
        }
      }
    }
    stage ("test") {
      steps {
        nodejs("System NodeJS") {
          sh "npm run test"
        }
      }
    }
    stage ("build") {
      steps {
        nodejs("System NodeJS") {
          sh "npm run build"
        }
      }
    }
    stage ("deploy") {
      when {
        branch '**/master'
      }
      steps {
        sshagent(['13e00839-0608-4e91-8b9e-cce3818425f3']) {
          sh "scp -o StrictHostKeyChecking=no -r dist/** www-data@sys.reslate.xyz:/srv/www/ent.sys.reslate.xyz"
        }
      }
    }
  }
}