ci: improve gradle error diagnosis with grep instead of tail

1 job for main in 3 minutes and 17 seconds
Status Job ID Name Coverage
  Build
failed #127727
studio-2023
ci-build

00:03:17

 
Name Stage Failure
failed
ci-build Build
BUILD SUCCESSFUL in 9s
86 actionable tasks: 45 executed, 41 up-to-date

For more on this, please refer to https://docs.gradle.org/8.10.2/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD FAILED in 26s
99 actionable tasks: 81 executed, 18 up-to-date
Cleaning up project directory and file based variables
ERROR: Job failed: exit status 1