67 lines
1.6 KiB
Groovy
67 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 --include=dev'
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Build') {
|
|
steps {
|
|
nodejs(nodeJSInstallationName: 'Node23') {
|
|
sh 'npm run build'
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Deploy to printer1') {
|
|
steps {
|
|
script {
|
|
def remote = [
|
|
name: 'printer1',
|
|
host: 'printer1.tombutcher.local',
|
|
user: 'ci',
|
|
port: 22,
|
|
credentialsId: 'ci_ssh',
|
|
allowAnyHosts: true
|
|
]
|
|
|
|
// Upload the build folder
|
|
sshPut remote: remote, from: 'build/', into: '/srv/farmcontrol-server/', flatten: false
|
|
|
|
// Restart the service
|
|
sshCommand remote: remote, command: 'sudo /bin/systemctl restart farmcontrol-server.service'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
post {
|
|
always {
|
|
cleanWs()
|
|
}
|
|
success {
|
|
echo 'Pipeline completed successfully!'
|
|
}
|
|
failure {
|
|
echo 'Pipeline failed!'
|
|
}
|
|
}
|
|
} |