-
Notifications
You must be signed in to change notification settings - Fork 64
Description
Affected version
1.2.2
Bug description
In a certain scenario, the build may result in a cache miss although the required cache entry is available on the remote cache.
The scenario is as follows (all builds on the same source code commit):
- Build runner A runs a build with -DskipTests and saves the result in the remote cache
- Build runner B runs a build with -DskipTests and loads the result from the remote cache (skipping the actual build)
- Build runner A runs a build without -DskipTests. Cache entry is found, but considered incomplete since skipTests was enabled. Tests are executed, and the result is saved in the remote cache again (under the same checksum, now with skipTests=false).
- Build runner B runs a build without -DskipTests. Now the bug can be observed.
Expected behavior
Build runner B should load the result from the remote cache (from step 3). Test execution should be skipped.
Actual behavior
Build runner B finds the downloaded cache entry from step 2 in its local cache and considers it as incomplete, without checking the remote cache. Tests are executed again.
Reproduce
The scenario can be reproduced with the attached demo project. reproducer.zip
Prerequisites:
Empty remote cache (Nexus 3) running under http://localhost:8081/repository/buildcache, settings.xml contains a corresponding entry like
<server>
<id>buildcache</id>
<username>ci</username>
<password>password</password>
</server>
Commands to execute in the "reproducer" directory:
rm -rf buildrunnerA_m2/build-cache
rm -rf buildrunnerB_m2/build-cache
mvn clean install -Dmaven.repo.local=buildrunnerA_m2/repository -Dmaven.build.cache.remote.save.enabled=true -f demo/pom.xml -DskipTests
mvn clean install -Dmaven.repo.local=buildrunnerB_m2/repository -Dmaven.build.cache.remote.save.enabled=true -f demo/pom.xml -DskipTests
mvn clean install -Dmaven.repo.local=buildrunnerA_m2/repository -Dmaven.build.cache.remote.save.enabled=true -f demo/pom.xml
mvn clean install -Dmaven.repo.local=buildrunnerB_m2/repository -Dmaven.build.cache.remote.save.enabled=true -f demo/pom.xml
Result:
[INFO] Attempting to restore project com.example:demo from build cache
[INFO] Downloaded build found by checksum b882441c46a44429
[INFO] Found cached build, restoring com.example:demo from cache by checksum b882441c46a44429
[INFO] Plugin parameter mismatch found. Parameter: skipTests, expected: true, actual: false
[INFO] Mojo cached parameters mismatch with actual, forcing full project build. Mojo: surefire:test
[INFO] A cached mojo is not consistent, continuing with non cached build
Workaround (not feasible in production!)
Delete buildrunnerB_m2/build-cache/v1.1/com.example/demo/b882441c46a44429/buildcache before step 4. Now the behavior is as expected:
->
[INFO] Attempting to restore project com.example:demo from build cache
[INFO] Downloading http://localhost:8081/repository/buildcache/v1.1/com.example/demo/b882441c46a44429/buildinfo.xml
[INFO] Found cached build, restoring com.example:demo from cache by checksum b882441c46a44429
[INFO] Downloading http://localhost:8081/repository/buildcache/v1.1/com.example/demo/b882441c46a44429/demo.jar
[INFO] Downloading http://localhost:8081/repository/buildcache/v1.1/com.example/demo/b882441c46a44429/demo-mvn-cache-ext-extra-output-1.zip