From: michaelbirnstiehl Date: Wed, 9 Sep 2020 21:27:25 +0000 (-0500) Subject: SONAR-13787 Clarify the PR analysis process X-Git-Tag: 8.5.0.37579~77 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=74393e4e8b46177475088aae7539c57c941ee963;p=sonarqube.git SONAR-13787 Clarify the PR analysis process --- diff --git a/server/sonar-docs/src/pages/analysis/jenkins.md b/server/sonar-docs/src/pages/analysis/jenkins.md index 137781aa0ce..7fd78f40f89 100644 --- a/server/sonar-docs/src/pages/analysis/jenkins.md +++ b/server/sonar-docs/src/pages/analysis/jenkins.md @@ -79,6 +79,9 @@ Starting in [Developer Edition](https://redirect.sonarsource.com/editions/develo For configuration examples, see the [SonarScanner for Jenkins](/analysis/scan/sonarscanner-for-jenkins/) documentation. +### Setting your Branch Source Plugin for Pull Request Decoration +You need to configure your Multibranch Pipeline job correctly to avoid issues with Pull Request decoration. From your Multibranch Pipeline job in Jenkins, go to **Configure > Branch Sources > Behaviors > Discover pull requests from origin** and make sure **The current pull request revision** is selected. + ## Detecting changed code in Pull Requests SonarScanners need access to a Pull Request's target branch to detect code changes in the Pull Request. If you're using a Jenkins Pull Request discovery strategy that only fetches the Pull Request and doesn't merge with the target branch, the target branch is not fetched and is not available in the local git clone for the scanner to read. @@ -93,3 +96,6 @@ To fix this, either change the discovery strategy or manually fetch the target b ``` git fetch +refs/heads/${CHANGE_TARGET}:refs/remotes/origin/${CHANGE_TARGET} ``` + + + diff --git a/server/sonar-docs/src/pages/analysis/pull-request.md b/server/sonar-docs/src/pages/analysis/pull-request.md index cd4f237a782..5205ac7c080 100644 --- a/server/sonar-docs/src/pages/analysis/pull-request.md +++ b/server/sonar-docs/src/pages/analysis/pull-request.md @@ -5,12 +5,16 @@ url: /analysis/pull-request/ _Pull Request analysis is available starting in [Developer Edition](https://redirect.sonarsource.com/editions/developer.html)._ -You can see your Pull Requests in SonarQube from the Branches and Pull Requests dropdown menu of your project. +You can see your Pull Requests in SonarQube from the Branches and Pull Requests dropdown menu of your project. -Pull Request analysis allows you to see your Pull Request's Quality Gate and analysis in the SonarQube interface: +Pull Request analysis shows your Pull Request's Quality Gate and analysis in the SonarQube interface. This analysis shows new issues introduced by the Pull Request before merging with the target branch: ![Pull Request Analysis.](/images/pranalysis.png) +## Prerequisites + +Before analyzing your Pull Requests, make sure the Pull Request branch is checked out. Avoid any attempt at previewing the merge or actions involving your main branch. + ## Pull Request Decoration You can also add Pull Request decoration that shows the Pull Request analysis and Quality Gate directly in your ALM's interface. See [Decorating Pull Requests](/analysis/pr-decoration/) for more information on setting it up. @@ -33,4 +37,4 @@ The following parameters enable PR analysis. | --------------------- | ---------------------------------- | | `sonar.pullrequest.key` | Unique identifier of your Pull Request. Must correspond to the key of the Pull Request in your ALM.
e.g.: `sonar.pullrequest.key=5` | | `sonar.pullrequest.branch` | The name of the branch that contains the changes to be merged.
e.g.: `sonar.pullrequest.branch=feature/my-new-feature` | -| `sonar.pullrequest.base` | The branch into which the Pull Request will be merged.
Default: master
e.g.: `sonar.pullrequest.base=master` | +| `sonar.pullrequest.base` | The branch into which the Pull Request will be merged.
Default: master
e.g.: `sonar.pullrequest.base=master` | \ No newline at end of file