pipeline {
    agent {
        docker { image 'node:14-alpine' }
    }

   stages {
        stage('checkout') {
          steps{
              git credentialsId: 'gitlab_token_api', poll: false, url: 'https://gitlab.com/group_rocho02/fitness-web.git'
          }
      }
      stage('Hello') {
         steps {

            sh 'node --version'

         }
      }
       stage('Build') {
         steps {

          sh '''cd customer/app
            npm i
            npm run build:prod-cutler-movar
            cd dist
            tar -czvf app.tar.gz app


            '''
         }


      }
       stage('upload') {
         steps {

          sshPublisher(publishers: [sshPublisherDesc(configName: 'websiter.hu', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '''
            pwd
            #bash /home/fitnessa/backup_fw.sh
            cd rocho/work
            tar -xvf app.tar.gz
            chown -R fitnessa.fitnessa app
            rm -rf/home/fitnessa/public_html/group-training
            mv app /home/fitnessa/public_html/group-training
          ''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: 'rocho/work', remoteDirectorySDF: false, removePrefix: 'customer/app/dist', sourceFiles: 'customer/app/dist/app.tar.gz')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: true)])
         }
      }
   }
}
