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
I've configured a pipeline with python build and deployment, but my pip cache is not working
Here is my bitbucket-pipelines.yml
- step: &pip-install
name: Install requirements
- pip install -r requirements.txt --trusted-host pypi.org --trusted-host files.pythonhosted.org --trusted-host pypi.python.org
- step: &cdk-deploy
- pipe: docker://bancosmartbank/bitbucket-pipe-cdk-pix-stack:1.7
- step: *pip-install
name: Deploy Test
After pip install -r requirements.txt the console shows me that the cache was found
Assembling contents of new cache 'pip'
Cache "pip": Compressing
Cache "pip": Compressed in 1 seconds
Cache "pip": Uploading 35.8 MiB
Cache "pip": Uploaded in 2 seconds
But on next step I've gotten this error
Traceback (most recent call last):
File "app.py", line 3, in <module>
from aws_cdk import core
ModuleNotFoundError: No module named 'aws_cdk'
Subprocess exited with error 1
Hi @Vitor Oliveira ,
If you check the "Build setup" in the Pipelines log of the second step, can you see a message about the cache being downloaded?
This is to confirm whether the cache is indeed being downloaded in the second step, or not.
If the cache is successfully downloaded for the second step, it will still not be available in the pipe.
When you execute a pipe, you have another Docker container (for the pipe) running inside the Docker container of the step (Docker-in-Docker).
The cache is available in the latter container (of the step), but not in the Docker container of the pipe.
In order to copy the cache from the step's container to the pipe's container, you can do the following:
1st In the bitbucket-pipelines.yml file, before the command with the pipe, add the following commands:
- cp -R ~/.cache ./
- chown -R 165536:165536 $BITBUCKET_CLONE_DIR
The first command will copy the cache directory from the root directory, to the clone directory (of the step container).
The second command will assign the permissions of the step's container to the pipe's container, which is needed for the 2nd step below.
2nd Now the cache will be present in the pipe's Docker container, but in the clone directory.
We'll need to move it from there to the root directory of the pipe's container.
To do this, you can edit the pipe.sh file of the pipe and add the command
cp -R ./.cache ~/
This will copy the cache from the clone directory of the pipe's container to the root directory, which is where the cache should be located.
This should work, assuming that the cache is downloaded for the second step, and also assuming that the error you get is because the cache is missing.
Please feel free to let us know if this works for you. In case you're still facing issues, my suggestion would be to open a ticket with Bitbucket Cloud support team via https://support.atlassian.com/contact/#/, you can link this post and also provide the URL of a build that fails with this error. If there is an open ticket, the engineer working on your case will be able to access the build and logs, which will allow for faster troubleshooting.
Please feel free to let me know if you have any questions.