pipeline { agent { label 'ubuntu' } environment { NODE_ENV = 'production' } stages { stage('Checkout') { steps { checkout scm } } stage('Setup Node.js') { steps { nodejs(nodeJSInstallationName: 'Node23') { sh 'node -v' sh 'yarn -v' } } } stage('Install Dependencies') { steps { nodejs(nodeJSInstallationName: 'Node23') { sh 'yarn install --frozen-lockfile --production=false' } } } stage('Run Tests') { steps { nodejs(nodeJSInstallationName: 'Node23') { sh ''' export NODE_ENV=test yarn test ''' } } post { always { junit 'test-results.xml' } } } stage('Deploy via SSH') { steps { sshPublisher(publishers: [ sshPublisherDesc( configName: 'farmcontrol.tombutcher.local', transfers: [ sshTransfer( cleanRemote: false, excludes: 'node_modules/**', execCommand: ''' cd /home/farmcontrol/farmcontrol-ws yarn install --production sudo systemctl restart farmcontrol-ws ''', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: 'farmcontrol-ws', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '**/*' ) ], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: true ) ]) } } } post { always { cleanWs() } } }