farmcontrol-api/Jenkinsfile
Tom Butcher 81b7dd6e16
Some checks failed
farmcontrol/farmcontrol-api/pipeline/head There was a failure building this commit
Switch to pnpm.
2026-02-01 21:42:17 +00:00

92 lines
2.6 KiB
Groovy

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 'pnpm -v'
}
}
}
stage('Install Dependencies') {
steps {
nodejs(nodeJSInstallationName: 'Node23') {
sh 'pnpm install --frozen-lockfile --production=false'
}
}
}
stage('Run Tests') {
steps {
nodejs(nodeJSInstallationName: 'Node23') {
sh '''
export NODE_ENV=test
export SESSION_SECRET=test-session-secret-for-testing-only
pnpm 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-api
pnpm install --production
sudo systemctl restart farmcontrol-api
''',
execTimeout: 120000,
flatten: false,
makeEmptyDirs: false,
noDefaultExcludes: false,
patternSeparator: '[, ]+',
remoteDirectory: 'farmcontrol-api',
remoteDirectorySDF: false,
removePrefix: '',
sourceFiles: '**/*'
)
],
usePromotionTimestamp: false,
useWorkspaceInPromotion: false,
verbose: true
)
])
}
}
}
post {
always {
cleanWs()
}
}
}