我遇到了一个问题。我想在启动作业时首先在应用程序中安装依赖项,然后运行它。下面是我的管道配置jenkins:
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'npm install'
}
}
stage('Run') {
steps {
sh 'npm start &'
}
}
}
}
一切构建无误
但应用程序,不幸的是,不启动.请帮助我,这里是日志:
Started by user admin
Obtained Jenkinsfile from git https://github.com/panic08/lapay-payment-frontendd
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /home/panic/.jenkins/workspace/Jenkins-testing
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
Selected Git installation does not exist. Using Default
The recommended git tool is: NONE
No credentials specified
> git rev-parse --resolve-git-dir /home/panic/.jenkins/workspace/Jenkins-testing/.git # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/panic08/lapay-payment-frontendd # timeout=10
Fetching upstream changes from https://github.com/panic08/lapay-payment-frontendd
> git --version # timeout=10
> git --version # 'git version 2.34.1'
> git fetch --tags --force --progress -- https://github.com/panic08/lapay-payment-frontendd +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision f0c9cf9c6f5d1708492c44cd77f2bf3178ece211 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f f0c9cf9c6f5d1708492c44cd77f2bf3178ece211 # timeout=10
Commit message: "v4.0"
> git rev-list --no-walk 975f62a81650b3e5a4e6f2b8c61ccc7f5423f214 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] sh
+ npm install
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@csstools/postcss-trigonometric-functions@1.0.2',
npm WARN EBADENGINE required: { node: '^14 || >=16' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@csstools/selector-specificity@2.2.0',
npm WARN EBADENGINE required: { node: '^14 || ^16 || >=18' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@testing-library/dom@9.2.0',
npm WARN EBADENGINE required: { node: '>=14' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: 'eslint-config-react-app@7.0.1',
npm WARN EBADENGINE required: { node: '>=14.0.0' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: 'less-loader@11.1.0',
npm WARN EBADENGINE required: { node: '>= 14.15.0' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: 'react-app-polyfill@3.0.0',
npm WARN EBADENGINE required: { node: '>=14' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: 'react-dev-utils@12.0.1',
npm WARN EBADENGINE required: { node: '>=14' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: 'react-scripts@5.0.1',
npm WARN EBADENGINE required: { node: '>=14.0.0' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }
up to date, audited 1514 packages in 14s
236 packages are looking for funding
run `npm fund` for details
6 high severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Run)
[Pipeline] sh
+ npm start
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
备注
如果我不是用npm start &启动它,而是用npm start,那么应用程序会启动,但jenkins不会进入下一个管道
1条答案
按热度按时间cyvaqqii1#
实际上,
npm start &
* 确实 * 启动了应用程序-但在后台。由于这是唯一要做的事情-在后台执行
npm start
-sh
命令执行,然后退出。Jenkins意识到“运行”阶段已经完成,清理并愉快地完成了。就像命令的那样。唯一剩下的人是打算做一些不同的事情的用户,这显然不仅很难向Jenkins解释。