gradle build: Usage, Options & Common CI Errors
The aggregate task - assemble plus check - that most CI jobs run.
build is Gradle’s aggregate lifecycle task that both assembles and tests the project. It depends on assemble (produce the outputs) and check (run all verification, including tests), so it is the usual one-shot CI command.
What it does
gradle build runs assemble + check. It compiles main and test code, produces artifacts (jar, etc.), and runs the test task plus any other checks. Always invoke via the wrapper (./gradlew) so the build uses the version pinned in gradle-wrapper.properties.
Common usage
./gradlew build
./gradlew build -x test # build but skip the test task
./gradlew build --scan # build + publish a build scan
./gradlew clean buildCommon error in CI (and the fix)
Symptom: "> Task :test FAILED" and "There were failing tests. See the report at: .../build/reports/tests/test/index.html". Cause: a unit test failed during the check part of build. Fix: open the linked HTML report (or the JUnit XML under build/test-results) to find the failing test, fix it, and re-run; to triage the assembly separately, run ./gradlew assemble or build -x test.