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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Pip Cache not working for next steps

Edited

I've configured a pipeline with python build and deployment, but my pip cache is not working

Here is my bitbucket-pipelines.yml

definitions: 
steps:
-
step: &pip-install
name: Install requirements
image: python:3.8.2
caches:
-
pip
script:
-
pip install -r requirements.txt --trusted-host pypi.org --trusted-host files.pythonhosted.org --trusted-host pypi.python.org

-
step: &cdk-deploy
caches:
-
pip
script:
-
pipe: docker://bancosmartbank/bitbucket-pipe-cdk-pix-stack:1.7
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_REGION: $AWS_REGION
ENV: $BITBUCKET_DEPLOYMENT_ENVIRONMENT
COMMAND: deploy
SERVICE: pix-stack-*

pipelines:
branches:
feature/*:
-
step: *pip-install
-
step:
<<: *cdk-deploy
name: Deploy Test
deployment: dev

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

CDK BootstrapTraceback (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 

 

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 17, 2021

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.

Kind regards,
Theodora

Suggest an answer

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

Atlassian Community Events