The “build-wrapper-dump.json” file was found empty on sonar-scanning-examples

Hi,

I fork sonar-scanning-examples for test analyze a C++ project on Github Action.
I always get the error message “The “build-wrapper-dump.json” file was found but 0 C/C++/Objective-C files were analyzed.”
I follow the readme on GitHub and steps on Sonarqube server.


I already create public repo GitHub - jeff51419/cpp-build-wrapper: source from https://github.com/SonarSource/sonar-scanning-examples/ and output log files on action flow.

build.yml

name: SonarQube
on:
  push:
    branches:
      - master # or the name of your main branch
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - 
        name: Checkout code
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - 
        name: Download and install the build wrapper, build the project
        run: |
          mkdir $HOME/.sonar
          curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip
          unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
          $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output ./build.sh
        env:
          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

      - 
        name: Verify build wrapper output
        run: |
          ls -lh bw-output
          cat bw-output/build-wrapper-dump.json
          cat bw-output/build-wrapper.log
      - 
        name: SonarQube analysis
        uses: SonarSource/sonarqube-scan-action@v1.0.0
        with:
          args: -Dsonar.cfamily.build-wrapper-output=bw-output
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

sonar-project.properties

sonar.projectKey=cpp-build-wrapper
sonar.projectName=cpp-build-wrapper
sonar.projectVersion=1.0

sonar.sources=src

# The build-wrapper output dir
sonar.cfamily.build-wrapper-output=bw-output

# Encoding of the source files
sonar.sourceEncoding=UTF-8

sonar.cfamily.threads=1
sonar.cfamily.cache.enabled=false

build.sh

#!/bin/bash
echo "REMOVE PREVIOUS BUILD"
rm -rf build

echo "BUILDING"
mkdir build
g++ -c -Wall -o build/BiggestUnInt src/BiggestUnInt.cc
g++ -c -Wall -o build/HelloWorld src/HelloWorld.cpp
g++ -c -Wall -o build/SimpleClass src/SimpleClass.cc
RC=$?

if [ $RC -ne 0 ]; then
  echo "BUILD FAILURE"
else
  echo "BUILD SUCCESS"
fi

I’d be obliged if someone point out what I miss or misunderstand.

Thanks in Advance,
Jeff

build-wrapper-dump.json (13.6 KB)
build-wrapper.log (40.4 KB)

json
“cwd”:"/home/runner/work/cpp-build-wrapper/cpp-build-wrapper"

log
working directory: </home/runner/work/cpp-build-wrapper/cpp-build-wrapper>

Hi @jeff51419
I’m Yacine and we discussed this together via email.
For the sake of consistency, let me sum up the conclusions that we have been reaching together.
The case that you have listed here, is due to the usage of the Github action.
As the documentation mentions, Github actions are not compatible with some languages, including the C/C++ project that you are trying to build.
You will find more following this link: GitHub - SonarSource/sonarqube-scan-action

Thanks :grinning:

Thanks a lot.

I also provide the github action yaml for someone want to use Github action.

name: SonarQube
on:
  push:
    branches:
      - master # or the name of your main branch
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - 
        name: Checkout code
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - 
        name: create .sonar folder
        run:  mkdir $HOME/.sonar

      - 
        name: Download and install the build wrapper, build the project
        run: |
          curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip
          unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
          $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output ./build.sh
        env:
          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

      - 
        name: Verify build wrapper output
        run: |
          ls -lh bw-output
          cat bw-output/build-wrapper-dump.json
          cat bw-output/build-wrapper.log

      - 
        name: Download and install the SonarScanner, scan the project
        run: |
          curl -sSLo $HOME/.sonar/sonar-scanner-cli-4.6.2.2472-linux.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-linux.zip
          unzip -o $HOME/.sonar/sonar-scanner-cli-4.6.2.2472-linux.zip -d $HOME/.sonar/
          echo "sonar.host.url=${SONAR_HOST_URL}" >> $HOME/.sonar/sonar-scanner-4.6.2.2472-linux/conf/sonar-scanner.properties
          $HOME/.sonar/sonar-scanner-4.6.2.2472-linux/bin/sonar-scanner -h
          $HOME/.sonar/sonar-scanner-4.6.2.2472-linux/bin/sonar-scanner -Dsonar.login=${SONAR_TOKEN}
        env:
          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.