Build cache miss: The task was not up-to-date because of the following reasons: Value of input property 'filter.commandLineIncludePatterns' has changed for task

When using the Gradle Build Cache in my CI environment I keep seeing the above error message causing Cache misses.
The only difference between the CI environment and running the build from my local machine (where everything is cached fine), is that the CI environment checks out the source code of the build into an arbitrary directory (with a different name for each run).
What directives or options do I have to avoid the above error?

Many thanks.

The above message is printed on the info log when the task is not up-to-date from the last run. It has not necessarily something to do with the build cache. Are you saying the task is always out of date on CI with this message?

For debugging cache misses see the build cache guide.

Cheers,
Stefan

Correct - the CI builds are continuously re-running the test tasks.
Is there a means of logging the cache key in the gradle server logs so as to identify what has changed between 2 runs of the same task?
Thanks.

Is there a means of logging the cache key in the gradle server logs so as to identify what has changed between 2 runs of the same task?

That is also described in the guide.

The not-up-to-date reason also points to filter.commandLineIncludePatterns being different. Those patterns a set by using the --tests command line option. Are you maybe passing different values in there?

Cheers,
Stefan

Not changing the command line options at all.

Here is the relevant output of the CI build log:

[15:50:49]Step 2/10: Unit tests (Command Line) (running for 54s)
[15:50:50][Step 2/10] Starting: /data/BuildAgent/temp/agentTmp/custom_script8045903261328007305
[15:50:50][Step 2/10] in directory: /data/BuildAgent/work/532924b656008991
[15:50:50][Step 2/10] Using Gradle Build Cache: http://gradle-build-client.westeurope.cloudapp.azure.com:5071/cache/
[15:50:50][Step 2/10] ++ export GRADLE_BUILD_CACHE_URL=http://gradle-build-client.westeurope.cloudapp.azure.com:5071/cache/
[15:50:50][Step 2/10] :core:test
[15:50:50][Step 2/10] ++ GRADLE_BUILD_CACHE_URL=http://gradle-build-client.westeurope.cloudapp.azure.com:5071/cache/
[15:50:50][Step 2/10] ++ export USE_GRADLE_DAEMON=false
[15:50:50][Step 2/10] ++ USE_GRADLE_DAEMON=false
[15:50:50][Step 2/10] ++ export GRADLE_CACHE_DEBUG=true
[15:50:50][Step 2/10] ++ GRADLE_CACHE_DEBUG=true
[15:50:50][Step 2/10] ++ export PERFORM_GRADLE_SCAN=--scan
[15:50:50][Step 2/10] ++ PERFORM_GRADLE_SCAN=--scan
[15:50:50][Step 2/10] ++ echo 'Using Gradle Build Cache: http://gradle-build-client.westeurope.cloudapp.azure.com:5071/cache/'
[15:50:50][Step 2/10] + echo :core:test
[15:50:50][Step 2/10] + cd core
[15:50:50][Step 2/10] + ../gradlew --stacktrace -Dorg.gradle.daemon=false -Dorg.gradle.caching.debug=true clean test --build-cache --scan

Hence I don’t understand why I am seeing filter.commandLineIncludePatterns has changed for task

Like I said above, please follow the steps in the in the build cache guide to compare the input hashes between the local run/server run and between two server runs. Which builds are storing artifacts in the build cache (push = true)?