Failed build using SonarCloud analyzing github Action CI

I’m trying to configure sonarcloud in a monorepo structure, Java 17 with Gradle 7.4, but it returns me with an error in Build and Analyze. says it didn’t find the Gradle build.
I believe I need to point the way, but I don’t know how.
Can anyone help?

Result Build and Analyze

Run ./back/condominioPlus/gradlew build sonarqube --info
Downloading https://services.gradle.org/distributions/gradle-7.4.1-bin.zip
...........10%...........20%...........30%...........40%...........50%...........60%...........70%...........80%...........90%...........100%
Initialized native services in: /home/runner/.gradle/native
Initialized jansi services in: /home/runner/.gradle/native

Welcome to Gradle 7.4.1!

Here are the highlights of this release:
 - Aggregated test and JaCoCo reports
 - Marking additional test source directories as tests in IntelliJ
 - Support for Adoptium JDKs in Java toolchains

For more details see https://docs.gradle.org/7.4.1/release-notes.html

Removing 0 daemon stop events from registry
Starting a Gradle Daemon (subsequent builds will be faster)
Starting process 'Gradle build daemon'. Working directory: /home/runner/.gradle/daemon/7.4.1 Command: /opt/hostedtoolcache/jdk/17.0.2/x64/bin/java --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/runner/.gradle/wrapper/dists/gradle-7.4.1-bin/58kw26xllvsiedyf3nujyarhn/gradle-7.4.1/lib/gradle-launcher-7.4.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 7.4.1
Successfully started process 'Gradle build daemon'
An attempt to start the daemon took 0.948 secs.
The client will now receive all logging from the daemon (pid: 1754). The daemon log file: /home/runner/.gradle/daemon/7.4.1/daemon-1754.out.log
Starting build in new daemon [memory: 512 MiB]
Closing daemon's stdin at end of input.
The daemon will no longer process any standard input.

Using 2 worker leases.
FAILURE: Build failed with an exception.

* What went wrong:
Directory '/home/runner/work/condominio/condominio' does not contain a Gradle build.

A Gradle build should contain a 'settings.gradle' or 'settings.gradle.kts' file in its root directory. It may also contain a 'build.gradle' or 'build.gradle.kts' file.

To create a new Gradle build in this directory run 'gradlew init'

For more detail on the 'init' task see https://docs.gradle.org/7.4.1/userguide/build_init_plugin.html

For more detail on creating a Gradle build see https://docs.gradle.org/7.4.1/userguide/tutorial_using_tasks.html

* Try:
> Run gradlew init to create a new Gradle build in this directory.
> Run with --stacktrace option to get the stack trace.
> Run with --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
Error: Process completed with exit code 1.

action file (github)

name: Build
on:
  push:
    branches:
      - main
      - origin/main
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
      - name: Set up JDK 17
        uses: actions/setup-java@v1
        with:
          java-version: 17
      - name: Cache SonarCloud packages
        uses: actions/cache@v1
        with:
          path: ~/.sonar/cache
          key: ${{ runner.os }}-sonar
          restore-keys: ${{ runner.os }}-sonar
      - name: Cache Gradle packages
        uses: actions/cache@v1
        with:
          path: ~/.gradle/caches
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
          restore-keys: ${{ runner.os }}-gradle
      - name: Grant execute permission for gradlew
        run: chmod +x ./back/condominioPlus/gradlew
      - name: Build and analyze
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        run: ./back/condominioPlus/gradlew build sonarqube --info 

Hey there.

What happens if you remove the sonarqube task from the Gradle command – does it still fail?

Removing build and analysis from sona git manages to finish the build

Result

Okay. What about just gradle build?

I need sonar to check the code. This code from build.yml was the sonarcloud site that delivers to create an action within git, but my project is in a subfolder the same as I put it in run on the last line, without this line the build works, but sonar doesn’t check .

Hey there.

What I’m suggesting is that you need to make sure gradle build works by itself before trying to run gradle build sonarqube – without gradle build (which it appears you’ve commented out entirely) – you aren’t actually building anything.