37 lines
1.1 KiB
Groovy
37 lines
1.1 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 stop ${env.JOB_NAME}"
|
|
}
|
|
}
|
|
stage('Build') {
|
|
steps {
|
|
sh './mvnw clean package'
|
|
}
|
|
}
|
|
stage('Deploy') {
|
|
environment {
|
|
PATH = "/var/lib/jenkins/.nvm/versions/node/v20.9.0/bin:${env.PATH}"
|
|
}
|
|
steps {
|
|
dir('/var/www/jerguero') {
|
|
// Remove previous deploy
|
|
sh 'rm /var/www/jerguero/*'
|
|
// Copy new deploy
|
|
sh 'cp /var/lib/jenkins/workspace/jerguero/target/jerguero-0.0.1.jar /var/www/jerguero'
|
|
// run jar with pm2
|
|
sh "pm2 start jerguero-0.0.1.jar --name ${env.JOB_NAME}"
|
|
// Save state
|
|
sh 'pm2 save'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|