npm 启动后 jenkins 管道未完成
jenkins pipeline not complete after npm start
我正在使用 Jenkins Pipeline 为我的 ReactJS 应用程序执行非常简单的构建自动化。
这是我的代码:
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'
}
}
}
}
我m doing is just to compile the application with npm install and then I
m 使用 npm start 在默认节点服务器上启动它。
发生的情况是 npm start 'never ending' 并且整个构建过程没有完成。
有什么建议可以让我 运行 服务器在最后一步不阻塞进程,以便它可以完成吗?
此致!
运行 npm start
作为 background/daemon 进程使用 forever
& 管道将成功。
$ forever start index.js
参考 - https://www.npmjs.com/package/forever
您也可以使用 nohup
。
$ nohup npm start &
我建议使用 forever,因为它已经非常流行地用于守护和监控您的 nodejs 应用程序。
永远足以从 Jenkins 管道启动应用程序。
但是如果你想要生产级别的流程管理器,你仍然可以考虑 PM2 和类似的工具,如 nodemon。
可以看到工具之间的对比
https://npmcompare.com/compare/forever,nodemon,pm2,strong-pm
我正在使用 Jenkins Pipeline 为我的 ReactJS 应用程序执行非常简单的构建自动化。 这是我的代码:
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'
}
}
}
}
我m doing is just to compile the application with npm install and then I
m 使用 npm start 在默认节点服务器上启动它。
发生的情况是 npm start 'never ending' 并且整个构建过程没有完成。
有什么建议可以让我 运行 服务器在最后一步不阻塞进程,以便它可以完成吗?
此致!
运行 npm start
作为 background/daemon 进程使用 forever
& 管道将成功。
$ forever start index.js
参考 - https://www.npmjs.com/package/forever
您也可以使用 nohup
。
$ nohup npm start &
我建议使用 forever,因为它已经非常流行地用于守护和监控您的 nodejs 应用程序。
永远足以从 Jenkins 管道启动应用程序。 但是如果你想要生产级别的流程管理器,你仍然可以考虑 PM2 和类似的工具,如 nodemon。
可以看到工具之间的对比 https://npmcompare.com/compare/forever,nodemon,pm2,strong-pm