farmcontrol-server/Jenkinsfile

64 lines
1.6 KiB
Groovy

pipeline {
agent any
environment {
NODE_ENV = 'production'
}
stages {
stage('Setup Node.js') {
steps {
nodejs(nodeJSInstallationName: 'Node23') {
sh 'node -v'
sh 'npm -v'
}
}
}
stage('Install Dependencies') {
steps {
nodejs(nodeJSInstallationName: 'Node23') {
sh 'npm ci'
}
}
}
stage('Build') {
steps {
nodejs(nodeJSInstallationName: 'Node23') {
sh 'npm run build'
}
}
}
stage('Deploy') {
steps {
echo 'Deploying application...'
sshagent(['printer1.tombutcher.local']) {
sh '''
# Create backup of current build
if [ -d /path/to/app/build ]; then mv /path/to/app/build /path/to/app/build.backup; fi
# Transfer new build
scp -r build/* /path/to/app/build/
# Restart the service
sudo systemctl restart your-service-name
'''
}
}
}
}
post {
always {
cleanWs()
}
success {
echo 'Pipeline completed successfully!'
}
failure {
echo 'Pipeline failed!'
}
}
}