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.
Hi @salgado18,
Thank you for reaching out to the community.
You can try to achieve this using the existing YAML configuration by disabling the clone in a specific step.
Here's the relevant documentation: Git clone options for pipelines - Clone
Here's an example where the first step will skip cloning and the second step will do the cloning.
pipelines: default: - step: clone: enabled: false script: - ls -R $BITBUCKET_CLONE_DIR - step: script: - ls -R $BITBUCKET_CLONE_DIR
Hope it helps and let me know how it goes.
Regards,
Mark C
Hi Marc, thanks for the answer.
My current steps are, in order:
- test the Angular part of the project;
- test the Java part of the project;
- compile the entire project;
- deploy it to the server.
The only way to avoid cloning and reimporting dependencies with the current options would be to join the first three steps into one, but that would remove the granularity of the pipeline.
The best scenario would be if it were possible to reuse the repository cloned in the first step on the second and third steps. After all, it is already in the local system folders, because it is a shell runner without docker containers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @salgado18,
In this case, I believe the best approach would be to disable clone in your YAML entirely and just manually clone your repository in the first step.
To disable clone, you can add this to your YAML configuration:
clone:
enabled: false
Once done, in your first step, you can then manually clone your repository and access the cloned repo folder in succeeding steps.
Let me know if you have any further questions.
Regards,
Mark C
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Simple and effective answer, thanks a lot.
If creating a config option in the pipeline to clone once is not viable, at least it would be nice to add a mention of it in the docs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.