I’m currently trying to move our Gradle (Android) build into a GitLab CI.
GitLab CI works in pipelines, where the pipeline consists of stages, and stages consist of jobs. The first stage in my case is called “build”, and it, well, builds. I call gradle assembleRelease
in this stage. If this stage succeeds, the build moves to the next stage in the pipeline. Stages are isolated from each other by fresh docker containers. However, build results can be defined as artifacts, and in this case, I defined the app/build folder as a build artifact, as it contains all the compiled .class files.
The second stage in the pipeline now copies this folder back into a fresh checkout of the project, and runs gradle testReleaseUnitTest
. I would expect gradle to notice that the project has already been built, and use the existing .class files, and only compile and run the tests. However, for some reason, gradle thinks my build files are out of date, and runs the whole build again, and then runs the tests. For smaller projects, this doesn’t take too long, but for our larger projects, this takes a significant amount of time that it shouldn’t take.
Anyone have hints as to why this is happening?