41 lines
1.2 KiB
Groovy
41 lines
1.2 KiB
Groovy
// Simple pipeline for deploying spring
|
|
pipeline {
|
|
agent any
|
|
stages {
|
|
stage('Stop previous deploy') {
|
|
environment {
|
|
PATH = "/var/lib/jenkins/.nvm/versions/node/v20.9.0/bin:${env.PATH}"
|
|
}
|
|
steps {
|
|
sh "pm2 delete ${env.JOB_NAME} || true"
|
|
}
|
|
}
|
|
stage('Build') {
|
|
steps {
|
|
sh './mvnw clean package'
|
|
}
|
|
}
|
|
stage('Deploy') {
|
|
environment {
|
|
PATH = "/var/lib/jenkins/.nvm/versions/node/v20.9.0/bin:${env.PATH}"
|
|
}
|
|
steps {
|
|
// Remove previous deploy
|
|
sh 'rm /var/www/jerguero/* || true'
|
|
// Copy new deploy
|
|
sh 'cp /var/lib/jenkins/workspace/jerguero/target/jerguero-0.0.1.jar /var/www/jerguero'
|
|
// Copy launch file
|
|
sh 'cp run.sh /var/www/jerguero'
|
|
|
|
// make launch file executable
|
|
sh 'chmod +x /var/www/jerguero/run.sh'
|
|
|
|
// run launch file with pm2
|
|
sh "pm2 start /var/www/jerguero/run.sh --name ${env.JOB_NAME}"
|
|
// Save state
|
|
sh 'pm2 save'
|
|
}
|
|
}
|
|
}
|
|
}
|