Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. New code changes pushed to Bitbucket (or new pull request is created)

    1. Bitbucket triggers your build pipeline for code changes

  2. Your build pipeline must trigger the Sonar analysis

    1. and executes the SonarScanneror one of its build system-dependent alternatives.

    2. see below for required parameters

  3. SonarQube informs Sonar for Bitbucket over a Webhook about a new analysis report.

    1. Sonar for Bitbucket annotates existing pull requests with the issues found in the analysis.

...

  1. Use Bitbucket Webhook to Jenkins or any other app to notify Jenkins about new code changes. See these instructions on how to set it up. It is important enabling the setting "Omit SHA1 Hash Code" in the repository settings of the app (see this issue on Github for more details).

  2. Follow the instructions on the Sonar Scanner for Jenkins Wiki to set up the SonarScanner configuration.

  3. The Jenkins Git plugin includes the origin/ prefix in branch names, which has to be removed. Use a Jenkins freestyle job.

    Code Block
    languagebash
    echo SONAR_BRANCH=$(printf '%s' $GIT_BRANCH | cut -d'/' -f 2-) > sonar-branch
  4. (Community Edition only) SonarQube versions 7.9.x and 8.x need to replace illegal branch characters.
    Use the following command to export the sanitized branch name to a file:

    Code Block
    echo SONAR_BRANCH=$(printf '%s' $GIT_BRANCH | cut -d'/' -f 2- | sed s/[^0-9a-zA-Z:_.\-]/'<YOUR_CONFIGURED_CHAR>'/g) > sonar-branch

...