During Npm install command in my pipeline, npm install fails to execute as it running with docker image: devxci/mbtci-java11-node18

I am trying to execute a pipeline job using pipers library into my jenkins. i am using the docker image: devxci/mbtci-java11-node18. to execute the build. however on the npm install command facing the below error:
referring pipers library = GitHub - SAP/jenkins-library: Jenkins shared library for Continuous Delivery pipelines.


+ docker pull devxci/mbtci-java11-node18
22:58:02  Using default tag: latest
22:58:02  latest: Pulling from devxci/mbtci-java11-node18
22:58:02  Digest: sha256:0f27d224b87a6fe946631d6acf37d56ba5ce07f4a9d19a6111dcd58e5ab93da7
22:58:02  Status: Image is up to date for devxci/mbtci-java11-node18:latest
22:58:02  docker.io/devxci/mbtci-java11-node18:latest
  [Pipeline] }
  [Pipeline] // withEnv
  [Pipeline] isUnix
  [Pipeline] withEnv
  [Pipeline] {
  [Pipeline] sh
22:58:03  + docker inspect -f . devxci/mbtci-java11-node18
22:58:03  .
  [Pipeline] }
  [Pipeline] // withEnv
  [Pipeline] withDockerContainer
22:58:04  Jenkins does not seem to be running inside a container
22:58:04  $ docker run -t -d -u 992:992 --env http_proxy --env https_proxy --env no_proxy --env HTTP_PROXY --env HTTPS_PROXY --env NO_PROXY -w /var/lib/jenkins/workspace/Data_Assist -v /var/lib/jenkins/workspace/Data_Assist:/var/lib/jenkins/workspace/Data_Assist:rw,z -v /var/lib/jenkins/workspace/Data_Assist@tmp:/var/lib/jenkins/workspace/Data_Assist@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** devxci/mbtci-java11-node18 cat
22:58:05  $ docker top 7645c9f880195f7da021f7d31fbab9e95afec891d09f03576f7ae4343ccf27f1 -eo pid,comm
  [Pipeline] {
  [Pipeline] withEnv
  [Pipeline] {
  [Pipeline] sh
22:58:06  + ./piper writePipelineEnv
22:58:07  time="2024-05-15T17:28:07Z" level=info msg="Version b388907b97af343b9497aee04160f6ae7078c321" library=SAP/jenkins-library
22:58:07  debug (noStepName) - Vault not configured
  [Pipeline] }
  [Pipeline] // withEnv
  [Pipeline] echo
22:58:07  Unstash content: pipelineStepReports
  [Pipeline] unstash
  [Pipeline] echo
22:58:07  Unstash failed: pipelineStepReports (No such saved stash ‘pipelineStepReports’)
  [Pipeline] withCredentials
  [Pipeline] {
  [Pipeline] sh
22:58:08  + ./piper mtaBuild --defaultConfig .pipeline/com.sap.piper/pipeline/stageOrdinals.yml --ignoreCustomDefaults
22:58:08  time="2024-05-15T17:28:08Z" level=info msg="Version b388907b97af343b9497aee04160f6ae7078c321" library=SAP/jenkins-library
22:58:08  debug mtaBuild - Vault not configured
22:58:08  debug mtaBuild - Retrieving hook configuration
22:58:08  debug mtaBuild - ConfigProvider options are not set. Provider configuration is skipped.
22:58:08  debug mtaBuild - For: STAGE_NAME, found: Pull-Request Voting
22:58:08  debug mtaBuild - For: JOB_URL, found: http://Auritas.jenkinsInstance/job/Data_Assist/
22:58:08  debug mtaBuild - For: BUILD_URL, found: http://Auritas.jenkinsInstance/job/Data_Assist/46/
22:58:08  debug mtaBuild - Launching mta build
22:58:08  debug mtaBuild - Project settings file not provided via configuration.
22:58:08  debug mtaBuild - Global settings file not provided via configuration.
22:58:08  info  mtaBuild - running command: npm config get registry
22:58:10  info  mtaBuild - Discovered pre-configured npm registry registry with value https://registry.npmjs.org/
22:58:10  
22:58:10  info  mtaBuild - "mta.yaml" file found in project sources
22:58:10  info  mtaBuild - No timestamp contained in "mta.yaml". File has not been modified.
22:58:10  debug mtaBuild - mtar name not provided via config. Extracting from file "mta.yaml"
22:58:10  debug mtaBuild - mtar name extracted from file "mta.yaml": "SAP-BTP-ASSIST-UI5-2"
22:58:10  info  mtaBuild - Executing mta build call: "mbt build --mtar SAP-BTP-ASSIST-UI5-2.mtar --platform CF --source ./ --target /var/lib/jenkins/workspace/Data_Assist"
22:58:10  info  mtaBuild - running command: mbt build --mtar SAP-BTP-ASSIST-UI5-2.mtar --platform CF --source ./ --target /var/lib/jenkins/workspace/Data_Assist
22:58:10  info  mtaBuild - [2024-05-15 17:28:10]  INFO Cloud MTA Build Tool version 1.2.27
22:58:10  info  mtaBuild - [2024-05-15 17:28:10]  INFO generating the "Makefile_20240515172810.mta" file...
22:58:10  info  mtaBuild - [2024-05-15 17:28:10]  INFO done
22:58:10  info  mtaBuild - [2024-05-15 17:28:10]  INFO executing the "make -f Makefile_20240515172810.mta p=CF mtar=SAP-BTP-ASSIST-UI5-2.mtar strict=true mode= t=\"/var/lib/jenkins/workspace/Data_Assist\"" command...
22:58:10  info  mtaBuild - [2024-05-15 17:28:10]  INFO validating the MTA project
22:58:10  info  mtaBuild - [2024-05-15 17:28:10]  INFO running the "before-all" build...
22:58:10  info  mtaBuild - [2024-05-15 17:28:10]  INFO executing the "npm install --verbose" command...
22:58:12  info  mtaBuild - npm verb cli /usr/local/bin/node /usr/local/bin/npm
22:58:12  info  mtaBuild - npm info using npm@9.5.1
22:58:12  info  mtaBuild - npm info using node@v18.16.1
22:58:12  info  mtaBuild - npm verb cache could not create cache: Error: EACCES: permission denied, mkdir '/.npm'
22:58:12  info  mtaBuild - npm verb logfile could not create logs-dir: Error: EACCES: permission denied, mkdir '/.npm'
22:58:12  info  mtaBuild - npm verb title npm install
22:58:12  info  mtaBuild - npm verb argv "install" "--loglevel" "verbose"
22:58:12  info  mtaBuild - npm verb logfile logs-max:10 dir:/.npm/_logs/2024-05-15T17_28_11_910Z-
22:58:12  info  mtaBuild - npm verb logfile could not be created: Error: ENOENT: no such file or directory, open '/.npm/_logs/2024-05-15T17_28_11_910Z-debug-0.log'
22:58:12  info  mtaBuild - npm verb logfile no logfile created
22:58:13  info  mtaBuild - npm verb stack Error: EACCES: permission denied, mkdir '/.npm'
22:58:13  info  mtaBuild - npm verb cwd /var/lib/jenkins/workspace/Data_Assist
22:58:13  info  mtaBuild - npm verb Linux 6.1.87-99.174.amzn2023.x86_64
22:58:13  info  mtaBuild - npm verb node v18.16.1
22:58:13  info  mtaBuild - npm verb npm  v9.5.1
22:58:13  error mtaBuild - npm ERR! code EACCES
22:58:13  error mtaBuild - npm ERR! syscall mkdir
22:58:13  error mtaBuild - npm ERR! path /.npm
22:58:13  error mtaBuild - npm ERR! errno -13
22:58:13  info  mtaBuild - npm verb Error: EACCES: permission denied, mkdir '/.npm' 
22:58:13  error mtaBuild - npm ERR! 
22:58:13  error mtaBuild - npm ERR! Your cache folder contains root-owned files, due to a bug in
22:58:13  error mtaBuild - npm ERR! previous versions of npm which has since been addressed.
22:58:13  error mtaBuild - npm ERR! 
22:58:13  error mtaBuild - npm ERR! To permanently fix this problem, please run:
22:58:13  error mtaBuild - npm ERR!   sudo chown -R 992:992 "/.npm"
22:58:13  info  mtaBuild - npm verb exit -13
22:58:13  info  mtaBuild - npm verb unfinished npm timer command:install 1715794091975
22:58:13  info  mtaBuild - npm verb unfinished npm timer reify 1715794091978
22:58:13  info  mtaBuild - npm verb unfinished npm timer reify:loadTrees 1715794091982
22:58:13  info  mtaBuild - npm verb unfinished npm timer idealTree 1715794091983
22:58:13  info  mtaBuild - npm verb unfinished npm timer idealTree:buildDeps 1715794092019
22:58:13  info  mtaBuild - npm verb unfinished npm timer idealTree:#root 1715794092020
22:58:13  info  mtaBuild - npm verb code -13
22:58:13  info  mtaBuild - 
22:58:13  error mtaBuild - npm ERR! Log files were not written due to an error writing to the directory: /.npm/_logs
22:58:13  error mtaBuild - npm ERR! You can rerun the command with --loglevel=verbose to see the logs in your terminal
22:58:13  error mtaBuild - ..[2024-05-15 17:28:13] ERROR the "before-all"" build failed: could not execute the "npm install --verbose" command: exit status 243
22:58:13  info  mtaBuild - Error: could not build the MTA project: could not execute the "make -f Makefile_20240515172810.mta p=CF mtar=SAP-BTP-ASSIST-UI5-2.mtar strict=true mode= t=\"/var/lib/jenkins/workspace/Data_Assist\"" command: exit status 2
22:58:13  error mtaBuild - [2024-05-15 17:28:13] ERROR could not build the MTA project: could not execute the "make -f Makefile_20240515172810.mta p=CF mtar=SAP-BTP-ASSIST-UI5-2.mtar strict=true mode= t=\"/var/lib/jenkins/workspace/Data_Assist\"" command: exit status 2
22:58:13  info  mtaBuild - fatal error: errorDetails{"category":"build","correlationId":"http://Auritas.jenkinsInstance/job/Data_Assist/46/","error":"running command 'mbt' failed: cmd.Run() failed: exit status 1","library":"SAP/jenkins-library","message":"failed to execute mta build","result":"failure","stepName":"mtaBuild","time":"2024-05-15T17:28:13.439426754Z"}
22:58:13  fatal mtaBuild - failed to execute mta build - running command 'mbt' failed: cmd.Run() failed: exit status 1
22:58:13  info  mtaBuild - persisting reports to GCS is disabled, because gcsBucketId is empty
22:58:13  debug mtaBuild - Could not read .pipeline/commonPipelineEnvironment/custom/cumulusPipelineID file: open .pipeline/commonPipelineEnvironment/custom/cumulusPipelineID: no such file or directory
22:58:13  debug mtaBuild - For: BUILD_URL, found: http://Auritas.jenkinsInstance/job/Data_Assist/46/
22:58:13  info  mtaBuild - Step telemetry data:{"StepStartTime":"2024-05-15 17:28:08.705118152 +0000 UTC","PipelineURLHash":"6bfa4ca3279f1d53422306ce0449884202cbb1a3","BuildURLHash":"23189ec947119fe20248c1a0931d10e038e61555","StageName":"Pull-Request Voting","StepName":"mtaBuild","ErrorCode":"1","StepDuration":"4757","ErrorCategory":"build","CorrelationID":"http://Auritas.jenkinsInstance/job/Data_Assist/46/","PiperCommitHash":"b388907b97af343b9497aee04160f6ae7078c321","ErrorDetail":{"category":"build","correlationId":"http://Auritas.jenkinsInstance/job/Data_Assist/46/","error":"running command 'mbt' failed: cmd.Run() failed: exit status 1","library":"SAP/jenkins-library","message":"failed to execute mta build","result":"failure","stepName":"mtaBuild","time":"2024-05-15T17:28:13.439426754Z"}}
  [Pipeline] }
  [Pipeline] // withCredentials
  [Pipeline] fileExists
  [Pipeline] fileExists
  [Pipeline] sh
22:58:15  + ./piper readPipelineEnv
22:58:15  time="2024-05-15T17:28:15Z" level=info msg="Version b388907b97af343b9497aee04160f6ae7078c321" library=SAP/jenkins-library
22:58:15  debug (noStepName) - Vault not configured
  [Pipeline] readJSON
  [Pipeline] echo
22:58:16  Transfer Influx data
  [Pipeline] findFiles
  [Pipeline] echo
22:58:16  Stash content: pipelineStepReports (includes: .pipeline/stepReports/**, excludes: , useDefaultExcludes: true, allowEmpty: true)
  [Pipeline] stash
22:58:16  Stashed 0 file(s)
  [Pipeline] fileExists
  [Pipeline] readJSON
  [Pipeline] error
  [Pipeline] }
22:58:16  $ docker stop --time=1 7645c9f880195f7da021f7d31fbab9e95afec891d09f03576f7ae4343ccf27f1
22:58:18  $ docker rm -f --volumes 7645c9f880195f7da021f7d31fbab9e95afec891d09f03576f7ae4343ccf27f1
  [Pipeline] // withDockerContainer
  [Pipeline] libraryResource
  [Pipeline] echo

need support in resolving the error.

Could you please make this test: on your machine first, run the devxci/mbtci-java11-node18 image with your source code directory mounted, and try the same command.
If it fails, your issue is not linked to Jenkins.
Thanks.

i tested it locally the docker image running the command it works. but in jenkins its failing.
also to highlight in logs i happen to see
following information in the logs:

Jenkins does not seem to be running inside a container
22:58:04 docker run -t -d -u 992:992 --env http_proxy --env https_proxy --env no_proxy --env HTTP_PROXY --env HTTPS_PROXY --env NO_PROXY -w /var/lib/jenkins/workspace/Data_Assist -v /var/lib/jenkins/workspace/Data_Assist:/var/lib/jenkins/workspace/Data_Assist:rw,z -v /var/lib/jenkins/workspace/Data_Assist@tmp:/var/lib/jenkins/workspace/Data_Assist@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** devxci/mbtci-java11-node18 cat 22:58:05 docker top 7645c9f880195f7da021f7d31fbab9e95afec891d09f03576f7ae4343ccf27f1 -eo pid,comm

can you suggest whats missing?
also i executed the same docker image reference in SAP BTP’s CI/CD service instance and its working fine but fails in jenkins

I’m sorry, but I don’t know. :person_shrugging: