Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-15029

Explain how to analyse C/C++/Objective C with Bitbucket Pipelines

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9.0
    • Component/s: Web
    • Labels:
      None
    • Edition:
      Developer
    • Production Notes:
      None

      Description

      We want to help users run an analysis for C/C++/Obj C code using Bitbucket Pipelines. Bitbucket Pipelines currently only supports Linux, so we will not provide an OS selector.

      image: gcc:8.5
      
      clone:
        depth: full
      
      pipelines:
        branches:
          '{master}':
            - step:
                name: Download and install the build wrapper, build the project
                script:
                - 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 <your clean build command>
                - pipe: sonarsource/sonarqube-scan:1.0.0
                  variables:
                    EXTRA_ARGS: -Dsonar.cfamily.build-wrapper-output=bw-output
                    SONAR_HOST_URL: ${SONAR_HOST_URL}
                    SONAR_TOKEN: ${SONAR_TOKEN}
      
        pull-requests:
          '**':
            - step:
                name: Download and install the build wrapper, build the project
                script:
                - 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 <your clean build command>
                - pipe: sonarsource/sonarqube-scan:1.0.0
                  variables:
                    EXTRA_ARGS: -Dsonar.cfamily.build-wrapper-output=bw-output
                    SONAR_HOST_URL: ${SONAR_HOST_URL}
                    SONAR_TOKEN: ${SONAR_TOKEN}
      

      Note: a potential improvement, which might impact existing tutorials, could be to use to use node anchors, so we write all the steps only once, and re-use them in branches and pull-requests (using the <<: *node_name syntax). See this repo for an example.

      Towards the end of the tutorial, add the following sentence (standard for all new C/C++/Obj C tutorials):

      If you have trouble using the build wrapper, you can check out using a compilation database. Read more about it here.
      You can speed up your analysis by enabling multi-threading and caching. Read more about it here.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jeremy.davis Jeremy Davis
              Reporter:
              wouter.admiraal Wouter Admiraal
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: