I ran into a problem. I want to first install the dependencies in the application when I start a Job and then run it. Here is my pipeline config jenkins:
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'npm install'
}
}
stage('Run') {
steps {
sh 'npm start &'
}
}
}
}
Everything builds without errors
But the application, unfortunately, does not start. Help me please, here are the logs:
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/[email protected]',
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/[email protected]',
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/[email protected]',
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: '[email protected]',
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: '[email protected]',
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: '[email protected]',
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: '[email protected]',
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: '[email protected]',
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
Note
If I don't start it with npm start &, but with npm start, then the application starts, but jenkins doesn't go to the next pipeline
Actually, npm start &
does start the application - but in the background.
As that is the sole thing to do - executing npm start
in the background - the sh
command does and then exits.
Jenkins realizes the "run" stage is done, cleans up and is happily done. As it was commanded to. The only person left alone is the user that meant to do something different, which is obviously not only hard to explain to Jenkins.