diff options
author | Michal Duda <michal.duda@sonarsource.com> | 2018-12-18 15:41:25 +0100 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-01-09 20:21:08 +0100 |
commit | db9ccd217314f45a612028ffcf64daff0169f370 (patch) | |
tree | d94a0a77a3e5e5f16fb86fae38b0c58562fe93f8 /server/sonar-docs/src/pages/sonarcloud | |
parent | e74dca535a14fc636b7dca18a5196d16ee3b365a (diff) | |
download | sonarqube-db9ccd217314f45a612028ffcf64daff0169f370.tar.gz sonarqube-db9ccd217314f45a612028ffcf64daff0169f370.zip |
SONAR-11594 scanner authentication token
Support passing the scanner authentication token with $SONAR_TOKEN
Diffstat (limited to 'server/sonar-docs/src/pages/sonarcloud')
-rw-r--r-- | server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud.md | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud.md b/server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud.md index 5485432ecf0..5ed96887e74 100644 --- a/server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud.md +++ b/server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud.md @@ -13,25 +13,34 @@ In Bitbucket Cloud, go to your team's "Settings > Find integrations" page, searc ## Analyzing with Pipelines -SonarCloud integrates with Bitbucket Pipelines to make it easier to trigger analyses. Follow the steps: +SonarCloud integrates with Bitbucket Pipelines to make it easier to trigger analyses. Follow these steps: -1. On SonarCloud, once your project is created, follow the tutorial on the dashboard of the project. You can copy-paste the command line displayed at the end. +1. On SonarCloud, once your project is created, follow the tutorial on the dashboard of the project. Copy-paste the command line displayed at the end but without the `sonar.login` setting. -2. On Bitbucket Cloud, go to the "Settings > Pipelines > Environment variables" page of your team, and add a new SONAR_TOKEN variable that contains the value of the SonarCloud token (something like `9ad01c85336b265406fa6554a9a681a4b281135f`) which you created during the tutorial (and which is available inside the command line that you copy-pasted). **Make sure that you click on the "Lock" icon to encrypt and hide this token.** +2. On Bitbucket Cloud, go to the "Settings > Pipelines > Account variables" page of your team, and add a new SONAR_TOKEN variable that contains the value of the SonarCloud token which you created during the tutorial (something like `9ad01c85336b265406fa6554a9a681a4b281135f`). **Make sure that you click on the "Lock" icon to encrypt and hide this token.** -3. Inside the `bitbucket-pipelines.yml` file of your repository, copy the command line provided by the tutorial and replace the actual token by its variable name. For example, for a Java Maven-based project, you should have something like: +3. Inside the `bitbucket-pipelines.yml` file of your repository paste the command you copied in step 1. For example, for a Java Maven-based project, you should have something like: ``` script: - -mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.projectKey=my-project -Dsonar.organization=my-team-org -Dsonar.login=$SONAR_TOKEN + -mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.projectKey=my-project -Dsonar.organization=my-team-org ``` -When this change on `bitbucket-pipelines.yml` is committed and pushed, Pipelines should automatically run a new build and therefore trigger the analysis of the repository. Shortly after, your project will appear on SonarCloud in your organization. +When this change on `bitbucket-pipelines.yml` is committed and pushed, Pipelines should automatically run a new build and therefore trigger the analysis of the repository. Shortly after, your project will appear on SonarCloud in your organization. -From now on, everytime Pipelines triggers a build, SonarCloud will: +## Analyzing pull requests with Pipelines -* Analyze every new branch that contains the change on the `bitbucket-pipelines.yml` file. -* Analyze and decorate every pull request based on such a branch. +In order to trigger SonarCloud analysis on each pull request update, you have to supply the copied command in `pull-requests` section of `bitbucket-pipelines.yml` (check [Configure bitbucket-pipelines.yml](https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html#Configurebitbucket-pipelines.yml-ci_pull-requests) for more details about that section). Here is a sample configuration: +``` +pipelines: + ... + pull-requests: + feature/*: + - step: + script: + - mvn -B verify sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.projectKey=... -Dsonar.organization=... + ... +``` ## Quality widget |