Here is our pipeline definition.
When running, I see that maven dependencies are downloaded on every run even pipeline is configured to use maven cache.
image: maven:3.9-eclipse-temurin-21 clone: depth: full # SonarCloud scanner needs the full history to assign issues properly definitions: caches: sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build steps: - step: &build-test-sonarcloud name: Build, test and analyze on SonarCloud caches: - maven - sonar script: - mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar artifacts: - target/** - step: &mirror-to-github name: Mirror to Github script: - git push --mirror git@github.com:{account}/{repo}.git pipelines: # More info here: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html custom: # Pipelines that can only be triggered manually sonar: - step: *build-test-sonarcloud branches: '{dev,*.X,*-sonar-*}': - step: *build-test-sonarcloud 'release/*': - step: *build-test-sonarcloud - step: *mirror-to-github pull-requests: '**': - step: *build-test-sonarcloud
Hi Andrius and welcome to the community!
There are a few things to check:
First, open the Pipelines page of the repo on Bitbucket's website. On this page, you will see a button named Caches near the top right corner (between the buttons Schedules and Usage). If you select the Caches button, do you see the maven cache listed?
If you don't see the maven cache listed there:
Open the page of a recent successful Pipelines build (cache is only generated on successful builds) that should generate this cache.
Select the step that should generate the cache, and then in this step's build log expand the Build teardown section.
What messages do you see there about the maven cache? Only caches under 1GB once compressed are saved. If your cache is larger than 1 GB or if there's any other issue (e.g. the cache directory is empty), there should be a message about it in the Build teardown section.
If you see a message about an empty cache, you can add the command ls -lahR ~/.m2/repository in the beginning and in the end of the script in the step that generates this cache to double check if it's empty. You will then need to check your build configuration and see if your dependencies are perhaps downloaded in a different directory (the directory ~/.m2/repository is used for the default maven cache in Pipelines).
Please also keep in mind that caches get removed one week after they are generated, but they should be repopulated on the next successful build.
If you see the maven cache listed there:
Have your project's dependencies perhaps changed since the cache was generated? I see in your bitbucket-pipelines.yml file that you are using static directory caching, and the cache doesn't get updated in this case if your dependencies change.
You can use a custom cache with file-based cache keys, so that a new cache gets generated when the file with your project dependencies gets updated:
Just a heads up, I edited the repo details from your yml to protect your privacy.
Please feel free to let me know your findings and if you have any questions.
Kind regards,
Theodora
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.