jerguero/Jenkinsfile.groovy

41 lines
1.2 KiB
Groovy
Raw Normal View History

2023-11-08 10:58:27 +00:00
// 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 {
2023-11-08 11:43:58 +00:00
sh "pm2 delete ${env.JOB_NAME} || true"
2023-11-08 10:58:27 +00:00
}
}
stage('Build') {
steps {
sh './mvnw clean package'
}
}
stage('Deploy') {
environment {
PATH = "/var/lib/jenkins/.nvm/versions/node/v20.9.0/bin:${env.PATH}"
}
steps {
2023-11-08 11:21:04 +00:00
// 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'
2023-11-08 11:29:12 +00:00
// Copy launch file
sh 'cp run.sh /var/www/jerguero'
2023-11-08 11:23:07 +00:00
2023-11-08 11:29:12 +00:00
// 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}"
2023-11-08 11:21:04 +00:00
// Save state
sh 'pm2 save'
2023-11-08 10:58:27 +00:00
}
}
}
}