You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
For the longest time these tests worked fine. Recently however they started failing only when run inside bitbucket-pipelines.
Here's a minimal reproduction https://bitbucket.org/ezequiel-wejugo/mockfs-bb-test/pipelines/results/1
What might be happening?
I imagine it could be to do with some security upgrade or other recent change on Bitbucket's side.
Just to give you some context, Bitbucket Pipelines builds run in Docker containers. For every step of the pipeline, a Docker container starts (the build container) using the image you have specified in your bitbucket-pipelines.yml file. The repo is cloned in that container and then the commands of that step's script are executed. When the step is finished, the container gets destroyed.
We have a guide for debugging Pipelines builds locally. Since you provided a public repo to reproduce, I cloned it and followed this guide.
In Step 2, I used the image node:20-alpine in the Dockerfile (the same one as your repo's). In Step 3, I used --entrypoint=/bin/sh in the command that starts the container (instead of --entrypoint=/bin/bash). The error that you see in the pipeline also occurs when debugging this locally, when I run the npm test command. So, it doesn't look like this is an issue with Bitbucket Pipelines infrastructure.
I would suggest checking the following guide, section "Scenario 1: Builds were successful earlier, but started failing recently" for possible causes and troubleshooting steps:
Please feel free to reach out if you have any questions!
Hi Theodora, thanks for the detailed response.
I run your steps locally and in my case the test passes.
In addition I run the container inside of a GKE kubernetes cluster to eliminate the possibility that running docker on Windows might be changing the result. Here too the test passes.
Assuming npm should detect a version/integrity discrepancy through the lock file, I cannot reconcile your run failing and mine succeeding.
Here's an attempt at custom integrity checking of my node_modules which is stable across installs:
$ find node_modules/ -type f | sort | xargs cat | sha512sum
Do you get the same checksum?
I got the same checksum as well.
Can you please confirm if you followed the same steps I am sharing below to debug this locally? This is just to confirm that you haven't done anything differently than me.
1. Create a directory for testingmkdir testdocker
2. Clone the repo in this new directorycd testdocker
git clone firstname.lastname@example.org:ezequiel-wejugo/mockfs-bb-test.git localDebugRepo
3. Reset the HEAD of the repository to the same commit as the failed Pipelines buildcd localDebugRepo
git reset --hard 48d74b4
4. Create a Dockerfile outside the clone dircd ..
5. Edit the Dockerfile and add this content:FROM node@sha256:37750e51d61bef92165b2e29a77da4277ba0777258446b7a9c99511f119db096
COPY ./localDebugRepo /localDebugRepo
I am pinning the Docker image to the same sha that the Pipelines build is using.
6. Build the Docker imagedocker build --memory=1g --memory-swap=1g -t myimage/test -f my.dockerfile .
7. Start a container using the image built in the previous step:docker run -it --memory=4g --memory-swap=4g --memory-swappiness=0 --cpus=4 --entrypoint=/bin/sh myimage/test
8. Inside the container, execute the commands of the repo's yml file
If you rerun the last successful build in the private repo, does it still succeed or does it fail?
Is the build image SHA the same or different in the last successful build and the first build that started failing (in your private repo)? You can find the image SHA if you expand the Build setup section in the Pipelines build log.
You are very welcome, Ezequiel!
If you want, you can pin an image by digest in your yml file to ensure that no changes can be introduced.
You can find an example here: