I`m working with Jenkins Pipeline to do very simple build automation for my ReactJS application. here is my code:
pipeline {
agent any
stages {
stage('Build') {
steps {
dir('react\\my-app') {
echo 'Start building process...'
bat 'npm install'
}
}
}
stage('Test') {
steps {
echo 'Testing.. //TODO run automation tests...'
}
}
stage('Deploy') {
steps {
echo 'Deployment steps.. //TODO copy build file to target folder...'
}
}
}
post {
success {
dir('react\\my-app') {
bat 'npm start'
}
}
}
}
What Im doing is just to compile the application with npm install and then I
m starting it on the default node server with npm start.
What happens is that npm start is 'never ending' and the whole build process does not complete.
Any suggestions how can I run the server at the last step without blocking the process, so that it can complete?
Best Regards !
Forever would be sufficient for kick starting the application from Jenkins pipeline. But if you want the process manager for the production level you can still consider PM2 and similiar tool like nodemon.
You can see the comparison between the tools https://npm-compare.com/forever,nodemon,pm2,strong-pm