Update Bitbucket Pipeline C/C++/Obj-C Example to Address Sonar Scanner Java Error

With the recent change to expect Java 17 or newer, the Bitbucket Pipeline example needs to be updated to address the following warning:

The version of Java (11.0.14.1) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.

The example is currently:

image: gcc:6.5

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

definitions:
  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:
          - sonar
        script:
          - export SONAR_SCANNER_VERSION=4.7.0.2747
          - export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
          - export BW_OUTPUT=$HOME/.sonar/bw-output
          - mkdir -p $BW_OUTPUT
          - curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
          - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
          - export PATH=$SONAR_SCANNER_HOME/bin:$PATH
          - curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
          - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
          - export PATH=$HOME/.sonar/build-wrapper-linux-x86:$PATH
          - build-wrapper-linux-x86-64 --out-dir $BW_OUTPUT <insert_your_clean_build_command>
          - sonar-scanner -Dsonar.cfamily.build-wrapper-output=$BW_OUTPUT

pipelines:                 # More info here: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
  branches:
    master:
      - step: *build-test-sonarcloud
  pull-requests:
    '**':
      - step: *build-test-sonarcloud
  • ALM used: Bitbucket Cloud
  • CI system used: Bitbucket Cloud
1 Like

Hey there.

Thanks for the report. I poked somebody about this yesterday. There’s an open ticket on our end.

In the meantime you can change this line:

      - export SONAR_SCANNER_VERSION=5.0.1.3006
1 Like

Thanks @Colin!