Failing bitbucket pipeline

I have created a bitbucket pipeline for a repository which has PHP files in majority of files but also has a little bit of cpp files which is making it difficult to deploy the code in sonarcloud .

image: composer:2.0 # Choose an image matching your project needs
options:
  docker: true
  size: 2x

clone:
  depth: full # SonarCloud scanner needs the full history to assign issues properly

definitions:
  services:
    docker:
      memory: 4096
  caches:
    sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build
  steps:
    - step: &build-test-sonarcloud
        name: Build, test and analyze on SonarCloud
        caches:
          - composer # See https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html
          - sonar
        script: # Build your project and run
          - pipe: sonarsource/sonarcloud-scan:1.2.0
    - step: &check-quality-gate-sonarcloud
        name: Check the Quality Gate on SonarCloud
        script:
          - pipe: sonarsource/sonarcloud-quality-gate:0.1.4

pipelines: # More info here: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
  branches:
    feature/*:
      - step: *build-test-sonarcloud
      - step: *check-quality-gate-sonarcloud
  pull-requests:
    "**":
      - step: *build-test-sonarcloud
      - step: *check-quality-gate-sonarcloud

The error I am receiving is : If you don't want to analyze C/C++/Objective-C files, then prevent them from being analyzed by setting the following properties:

``

sonar.c.file.suffixes=-

sonar.cpp.file.suffixes=-

sonar.objc.file.suffixes=-

Any suggestions what I should do here ?

Hello @Ali_Hussaini. I think this message is a warning, not an error. SonarCloud proceed with the analysis of the CPP files and the message is telling you how to avoid them to be scanned, otherwise the analysis results will include those files. I imagine that you don’t want this, right? them you can just add the properties as suggested.

Actually its refusing to build the pipeline the error is
execution failure

Could you please provide the full scanner log?

Sure , the pipeline code for the following is :

image: python:3.8 
options:
  docker: true
  size: 2x
clone:
  depth: full 
definitions:
  services:
    docker:
      memory: 4096
  caches:
    sonar: ~/.sonar/cache 
  steps:
    - step: &build-test-sonarcloud
        name: Build, test and analyze on SonarCloud
        caches:
          - pip 
          - sonar
        script:
     
          #- python3 -m unittest discover 
          - pipe: sonarsource/sonarcloud-scan:1.2.0

    - step: &check-quality-gate-sonarcloud
        name: Check the Quality Gate on SonarCloud
        script:
          - pipe: sonarsource/sonarcloud-quality-gate:0.1.4

pipelines: 
  branches:
    feature/*:
      - step: *build-test-sonarcloud
      - step: *check-quality-gate-sonarcloud
    master:
      - step: *build-test-sonarcloud
      - step: *check-quality-gate-sonarcloud

  pull-requests:
    "**":
      - step: *build-test-sonarcloud
      - step: *check-quality-gate-sonarcloud

The pipeline logs are causing the same error of Execution failure pipelineLog-1.txt (15.9 KB)

@Ali_Hussaini, to proceed with the analysis of C/CPP files you need to fulfill the prerequisites. If you don’t want/need to analyse such files, then proceed with the error instructions (suffixes properties) to ignore those files.

@Alexandre_Holzhey how would I ignore those files is it just putting those
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-

in the bitbucket pipeline and modify the code like this :

image: python:3.8
options:
docker: true
size: 2x
clone:
depth: full
definitions:
services:
docker:
memory: 4096
caches:
sonar: ~/.sonar/cache
steps:
- step: &build-test-sonarcloud
name: Build, test and analyze on SonarCloud
caches:
- pip
- sonar
script:

      #- python3 -m unittest discover 
      - pipe: sonarsource/sonarcloud-scan:1.2.0

- step: &check-quality-gate-sonarcloud
    name: Check the Quality Gate on SonarCloud
    script:
      - pipe: sonarsource/sonarcloud-quality-gate:0.1.4
      - sonar.c.file.suffixes=-
      - sonar.cpp.file.suffixes=-
      - sonar.objc.file.suffixes=-

pipelines:
branches:
feature/*:
- step: *build-test-sonarcloud
- step: *check-quality-gate-sonarcloud
master:
- step: *build-test-sonarcloud
- step: *check-quality-gate-sonarcloud

pull-requests:
“**”:
- step: *build-test-sonarcloud
- step: *check-quality-gate-sonarcloud

These analysis parameters can be added to sonar-project.properties file. You can have a look into this example. Please let me know if this helps you.

Hi thanks for the solution I actually got a solution using the Administration -> General settings -> Analysis scope and simply added file extensions for ignore in sonar cloud it worked this way !

I also had the same problem, after days of searching, I finally read this page Bitbucket
Then to ignore analyze C/C++/Objective-C files in bitbucket-pipelines.ylm file i add:

      script:
        - pipe: sonarsource/sonarcloud-scan:1.2.1
          variables:
            EXTRA_ARGS: -Dsonar.c.file.suffixes=- -Dsonar.cpp.file.suffixes=- -Dsonar.objc.file.suffixes=- -Dsonar.projectVersion=1.0 -Dsonar.sourceEncoding=UTF-8

Hope it is useful for you guys

1 Like