On Travis CI, never call exit in your script phase if you want caching (or anything after script) to run. It kills the worker immediately; let the script finish normally so the cache stage executes.

Context: From a Travis CI community forum thread, resolved by the reporter. A Maven build completed successfully but the local repository was never cached. The cause: the build script called exit, which terminated the worker before the cache-upload stage ran. Removing the exit call fixed caching. Anything that ends the worker early, even on success, skips the stages after script.