Catching Gradle Test Executor exit value 137

Occasionally our CI pipeline is experiencing the following error message when running ./gradlew test

> Process 'Gradle Test Executor 23' finished with non-zero exit value 137

From my understanding this is due to the OS killing the Gradle Test Worker JVM. Our JVM settings are the following:

    maxHeapSize = "8g"
    maxParallelForks = (Runtime.runtime.availableProcessors() / 1.33) ?: 1
    forkEvery = 1

I have tried lowering maxHeapSize but our tests require a minimum β€œ8g”.

That being said I would like to catch if a Gradle Test Executor reports a non-zero exit value of 137 but the exit value of the ./gradlew test process is 1 instead of 137 so I can’t distinguish between actual test failures vs. Gradle Test Executor OOM.

How do I catch if ./gradlew test exited due to test executor with non-zero exit value of 137?

1 Like