Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket pipeline npm docker build fails exit code: 137

Iwan van Staveren
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 6, 2024

When I run the build <redacted> it fails with

 

Memory usage in bytes:
15794
138018816
15795
#10 1691.2 Killed
15796
#10 ERROR: process "/bin/sh -c npm install && BUILD_NUMBER=\"${BUILD_NUMBER}\" npm --report-on-fatalerror --report-on-signal --max-old-space-size=2048 run build-prod" did not complete successfully: exit code: 137
15797
------
15798
> [build-nodejs 4/4] RUN npm install && BUILD_NUMBER="267" npm --report-on-fatalerror --report-on-signal --max-old-space-size=2048 run build-prod:
15799
------
15800
process "/bin/sh -c npm install && BUILD_NUMBER=\"${BUILD_NUMBER}\" npm --report-on-fatalerror --report-on-signal --max-old-space-size=2048 run build-prod" did not complete successfully: exit code: 137
15801
task: Failed to run task "build": exit status 1

I have the memory use logs on. That doesn't seem to kill it. It is getting lower and still fine.

Memory usage in bytes:
15692
138735616
15693
Wed Mar 6 08:50:25 UTC 2024
15694
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
15695
root 1 0.0 0.0 2892 972 ? Ss 08:21 0:00 /bin/sh -c exit $( (/usr/bin/mkfifo /opt/atlassian/pipelines/agent/tmp/build_result && /bin/cat /opt/atlassian/pipelines/agent/tmp/build_result) || /bin/echo 1)
15696
root 7 0.0 0.0 2892 108 ? S 08:21 0:00 /bin/sh -c exit $( (/usr/bin/mkfifo /opt/atlassian/pipelines/agent/tmp/build_result && /bin/cat /opt/atlassian/pipelines/agent/tmp/build_result) || /bin/echo 1)
15697
root 8 0.0 0.0 3216 1016 ? S 08:21 0:00 /bin/cat /opt/atlassian/pipelines/agent/tmp/build_result
15698
root 10 0.0 0.0 2892 976 ? Ss 08:21 0:00 /bin/sh /opt/atlassian/pipelines/agent/tmp/wrapperScript3458278447178824736.sh
15699
root 39 0.0 0.0 2892 952 ? S 08:21 0:00 /bin/sh /opt/atlassian/pipelines/agent/tmp/buildScript11719303506556174579.sh
15700
root 40 0.0 0.0 8872 7552 ? S 08:21 0:00 /bin/bash -i /opt/atlassian/pipelines/agent/tmp/bashScript17359917558946570271.sh
15701
root 177 0.0 0.0 8872 5976 ? S 08:21 0:00 /bin/bash -i /opt/atlassian/pipelines/agent/tmp/bashScript17359917558946570271.sh
15702
root 178 0.0 0.0 8872 5976 ? S 08:21 0:00 /bin/bash -i /opt/atlassian/pipelines/agent/tmp/bashScript17359917558946570271.sh
15703
root 181 0.0 0.0 1233440 8940 ? Sl 08:21 0:00 task build -- GEN-114_backpack_storage-2024.03.06.0267
15704
root 190 0.3 0.1 755392 37000 ? Sl 08:21 0:06 docker build --pull -t <redacted> --build-arg BACKPACK_USER=$BACKPACK_USER --build-arg BACKPACK_PASSWORD=$BACKPACK_PASSWORD --build-arg ENV=prod --build-arg BUILD_NUMBER=267 .
15705
root 4458 0.0 0.0 3212 988 ? S 08:50 0:00 sleep 2
15706
root 4460 0.0 0.0 7484 3372 ? R 08:50 0:00 ps aux


So my guess is something related to docker daemon. But how do I check that?

Works fine on my local system.

1 answer

1 vote
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 7, 2024

Hello @Iwan van Staveren and welcome to the Community!

The exit code 137 returned by npm command usually indicates a memory allocation issue, where npm is exceeding the current available memory in the environment.

Looking at the logs you shared with us, it seems like you are executing the npm command as part of a docker build (the npm command is inside a Dockerfile). Could you confirm if that is the case?

If yes, then I would suggest increasing the memory allocated to the docker service and verifying if it solves the issue. By default, the docker service in pipelines is allocated with 1GB of memory, out of the 4GB available for the step (8GB for size:2x steps)

You can increase the memory allocated for docker service up to 3GB for normal steps, and 7GB for size: 2x steps.

For that, you'd need to add a definition to your bitbucket-pipelines.yml file configuring the amount of memory you want. Following is an example of configuring the docker service to use 2GB of memory : 

definitions:
services:
docker:
memory: 2048 # increase the memory for docker service from 1GB to 2GB

You can start testing with 2GB, and then tweak that value according to the amount of memory used by your build and the commands you are executing in your pipeline.

For more details on how memory allocation works in pipelines, the following article may also be of help : 

Hope that helps! Should you have any questions, feel free to ask.

Thank you, @Iwan van Staveren !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events