I have a Bitbucket pipeline that runs Maven several times in several steps. However, it appears that most (all?) of what is needed by Maven misses the cache no matter how many times I run the build within the week. I'm hoping that the issue is one of my misunderstanding on how to use the cache. What is the proper way to use a Maven cache in a muilt-step build?
Note: this is NOT a multi-module Maven build (in case that makes a difference)
Additional Question: Does the cache get updated with additional dependencies throughout the build or does it only get picked up for one of the steps?
This is an example of one of my pipelines that exhibits the behavior (the paste into this editor ate the formatting, so I apologize if there's some mis-aligned whitespace invalidating the YAML).
definitions:
steps:
- step: &build-test
name: Build and Test
caches:
- maven
script:
- mvn verify
pipelines:
default:
- step: *build-test
branches:
master:
- step:
name: Set Version and Environment
caches:
- maven
script:
- >
mvn build-helper:parse-version versions:set
-DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}-${BITBUCKET_BUILD_NUMBER}
- >
echo "export VERSION=$(mvn help:evaluate
-Dexpression=project.version
-q -DforceStdout)" > version
artifacts:
- pom.xml
- version
- step:
name: Build, Test, Package, and Publish
caches:
- maven
script:
- source ./version
- mvn verify
- step:
name: Update Versions and Push
caches:
- maven
script:
# Commit and tag the built release version
- mvn scm:add@add scm:checkin scm:tag@tag -Dscm=rel
# Set the new development version
- >
mvn build-helper:parse-version versions:set
-DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}-SNAPSHOT
# Commit the new development version
- mvn scm:add@add scm:checkin -Dscm=dev
pull-requests:
'**':
- step:
<<: *build-test
after-script:
- pipe: atlassian/checkstyle-report:0.3.0