I found this answer about cloning the repo once in the pipeline, and read the nice explanation about the process:
https://community.atlassian.com/t5/Bitbucket-questions/Clone-a-git-repo-jus-once/qaq-p/1880630
But it assumes the pipeline is running in BitBucket's infrastructure, or at least in a docker environment. When running in a shell environment, everything happens in a folder in the server machine, so there are no docker images to handle.
Is it possible to set it up so that the clone process happens only in one step, and then it is reused in the next steps? I ask this not for the clone itself (despite the large use of network for all the clones), but I have to reimport dependencies all over again. Cache works great for the download part, but once it is downloaded, some systems have to compile them, and it happens every time.
As an example, I have a Linux Shell runner in my local machine, with plenty of cores and memory. The pipeline takes 8 minutes to run, while the local script (which does the same things, minus the imports) takes less than 2 minutes. I believe it could go down to at most 3 or 4 minutes, if the clone happens in the beginning.