aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormickael-caro-sonarsource <50556955+mickael-caro-sonarsource@users.noreply.github.com>2019-07-08 13:30:11 +0200
committersonartech <sonartech@sonarsource.com>2019-07-10 08:36:51 +0200
commitfbcd3b7693d858542eb778baf6e85ebedea3b51a (patch)
treeef62594a7dcd744ba689556671c156f1a2bdb1b9
parent8d317e8bffa615d38ecc24d5715060f66f58860a (diff)
downloadsonarqube-fbcd3b7693d858542eb778baf6e85ebedea3b51a.tar.gz
sonarqube-fbcd3b7693d858542eb778baf6e85ebedea3b51a.zip
MMF-1737 Analyze Bitbucket repositories with Azure Pipelines (#1879)
* SC-762- Tutorial for new BbC projects should mention support of Azure Pipelines * Updated tutorial for bitbucketcloud * SC-801 - Organization and its eventual app install related entity are now mandatory while targeting a bound project on ALMs. * SC-801 --TEMP Added INFO logs * SC-801 - Added back return of alm binding if no project alm is present. * SC-801 - Fixed added log, failing unit tests before. * SC-801 - Added extra logs (TEMP) * SC-801 - Reverted unwanted imports. * SC-801 - Adaptation of UT following the add of logs TO BE REVERTED ONCE OK * SC-801 - Changed newly added log levels to debug to see if they are popping in the CE logs. * SC-801 - Add constant for Bitbucket API Version in its REST client. * SC-760 - Updated documentation to support Azure Pipelines. * SC-801 - Reverted all temporary logs * fixup! SC-760 - remove inside file links to avoid failing of unint tests. * SC-801 - Fixes after review * SC-760 - Splited documentation to 3 in total, with azure pipelines and bitbucket pipelines. * SC-762 - Updated Snapshot * SC-762 - Updated onboarding tutorial + documentation * SC-762 - Updated formating of .tsx following yarn validate. * SC-801 - Added unit tests + removed codesmell * SC-760 - Updated documentation markdowns for Bitbucket. * SC-801 - Removed unused import. * SC-801 - Updated failing unit tests. * SC-801 - Fix typo * SC-801 - Resolving issues following analysis by SQ
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallDao.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallMapper.java2
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/alm/AlmAppInstallMapper.xml3
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/alm/AlmAppInstallDaoTest.java6
-rw-r--r--server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud-azurepipelines.md36
-rw-r--r--server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud-bitbucketpipelines.md42
-rw-r--r--server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud.md31
-rw-r--r--server/sonar-web/src/main/js/apps/tutorials/analyzeProject/AnalyzeTutorialSuggestion.tsx14
-rw-r--r--server/sonar-web/src/main/js/apps/tutorials/analyzeProject/__tests__/__snapshots__/AnalyzeTutorialSuggestion-test.tsx.snap17
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties4
10 files changed, 103 insertions, 56 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallDao.java
index ba309a409d7..a4515770506 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallDao.java
@@ -66,9 +66,9 @@ public class AlmAppInstallDao implements Dao {
return Optional.ofNullable(mapper.selectByInstallationId(alm.getId(), installationId));
}
- public Optional<AlmAppInstallDto> selectByOrganization(DbSession dbSession, ALM alm, OrganizationDto organization) {
+ public Optional<AlmAppInstallDto> selectByOrganization(DbSession dbSession, OrganizationDto organization) {
AlmAppInstallMapper mapper = getMapper(dbSession);
- return Optional.ofNullable(mapper.selectByOrganizationUuid(alm.getId(), organization.getUuid()));
+ return Optional.ofNullable(mapper.selectByOrganizationUuid(organization.getUuid()));
}
public List<AlmAppInstallDto> selectByOrganizations(DbSession dbSession, List<OrganizationDto> organizations) {
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallMapper.java
index f7fee75e02e..b5f703a166d 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallMapper.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/alm/AlmAppInstallMapper.java
@@ -37,7 +37,7 @@ public interface AlmAppInstallMapper {
AlmAppInstallDto selectByUuid(@Param("uuid") String uuid);
@CheckForNull
- AlmAppInstallDto selectByOrganizationUuid(@Param("alm") String alm, @Param("organizationUuid") String organizationUuid);
+ AlmAppInstallDto selectByOrganizationUuid(@Param("organizationUuid") String organizationUuid);
List<AlmAppInstallDto> selectUnboundByUserExternalId(@Param("userExternalId") String userExternalId);
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/alm/AlmAppInstallMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/alm/AlmAppInstallMapper.xml
index 96ef69dd550..57bd49a7538 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/alm/AlmAppInstallMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/alm/AlmAppInstallMapper.xml
@@ -46,8 +46,7 @@
alm_app_installs aai
inner join organization_alm_bindings oab on oab.alm_app_install_uuid = aai.uuid
where
- oab.alm_id = #{alm, jdbcType=VARCHAR}
- and oab.organization_uuid = #{organizationUuid, jdbcType=VARCHAR}
+ oab.organization_uuid = #{organizationUuid, jdbcType=VARCHAR}
</select>
<select id="selectByOrganizationUuids" parameterType="String" resultType="org.sonar.db.alm.AlmAppInstallDto">
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/alm/AlmAppInstallDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/alm/AlmAppInstallDaoTest.java
index 9fa07f3629f..612d47d009a 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/alm/AlmAppInstallDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/alm/AlmAppInstallDaoTest.java
@@ -158,9 +158,9 @@ public class AlmAppInstallDaoTest {
AlmAppInstallDto install = insertAlmAppInstall(organization);
db.commit();
- assertThat(underTest.selectByOrganization(db.getSession(), GITHUB, organization).get().getUuid()).isEqualTo(install.getUuid());
- assertThat(underTest.selectByOrganization(db.getSession(), BITBUCKETCLOUD, organization)).isEmpty();
- assertThat(underTest.selectByOrganization(db.getSession(), GITHUB, new OrganizationDto().setUuid("other-organization"))).isEmpty();
+ assertThat(underTest.selectByOrganization(db.getSession(), organization).filter(o -> o.getAlm() == GITHUB).get().getUuid()).isEqualTo(install.getUuid());
+ assertThat(underTest.selectByOrganization(db.getSession(), organization).filter(o -> o.getAlm() == BITBUCKETCLOUD)).isEmpty();
+ assertThat(underTest.selectByOrganization(db.getSession(), new OrganizationDto().setUuid("other-organization")).filter(o -> o.getAlm() == GITHUB)).isEmpty();
}
@Test
diff --git a/server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud-azurepipelines.md b/server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud-azurepipelines.md
new file mode 100644
index 00000000000..7c27d6538ed
--- /dev/null
+++ b/server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud-azurepipelines.md
@@ -0,0 +1,36 @@
+---
+title: Analyze your repository with Azure Pipelines
+nav: With Azure Pipelines
+url: /integrations/bitbucketcloud/azure-pipelines/
+---
+
+If you are analyzing .NET applications and want to benefit from the Azure DevOps / Pipelines experience and features, you have the possibility to setup a build pipeline, targeting your Bitbucket Cloud repository, and connected to SonarCloud.
+
+## Analyzing branches
+
+Please be advised that the team where the Bitbucket Cloud repository is has to be bound to your SonarCloud organization in order to get this work.
+
+1. Install the SonarCloud extension for Azure DevOps in your Azure DevOps organization : [SonarCloud extension](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarcloud). You can have a look a [this chapter](https://docs.microsoft.com/en-us/labs/devops/sonarcloudlab/index?tutorial-step=1) of the global tutorial for Azure DevOps.
+
+2. Configure a new build pipeline (YAML or classic editor), targeting your Bitbucket Cloud repository. You will have to create a new service connection to that repository.
+
+3. Configure the Prepare SonarCloud configuration task just the way you will do for a regular Azure Git Repository.
+
+4. Go to the triggers tab of the pipeline configuration, click on the repository below `Continuous Integration` then click on `Enable continuous integration`, add a new branch filter with following configuration :
+ * Type : Include
+ * Branch specification : master
+
+Want to see how it is working ? Have a look at our [sample .NET project](https://bitbucket.org/sonarsource/sample-dotnet-project-azuredevops)
+
+## Analyzing pull requests
+
+Pre-requisites :
+
+* Follow the initiation steps of Analyzing branches with Azure pipelines above.
+* Version 1.6.4+ of the Azure DevOps extension is needed.
+
+As for branches, you can trigger an analysis for Pull requests with an Azure DevOps pipeline and get your PR decorated.
+
+1. On the Azure pipeline that will be used, click on the `Triggers` tab, then click on the repository below `Pull request validation`
+
+2. Click on `Enable pull request validation` then configure the proper branch filters.
diff --git a/server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud-bitbucketpipelines.md b/server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud-bitbucketpipelines.md
new file mode 100644
index 00000000000..e4be9b8c930
--- /dev/null
+++ b/server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud-bitbucketpipelines.md
@@ -0,0 +1,42 @@
+---
+title: Analyze your repository with Bitbucket Pipelines
+nav: With Bitbucket Pipelines
+url: /integrations/bitbucketcloud/bitbucket-pipelines/
+---
+
+## Analyzing branches
+
+Once your project is created and initiated from the repository you selected:
+
+1. Generate a token to allow to publish analysis from Bitbucket Pipelines. To generate a token, follow the first step of the tutorial on the dashboard of the project, or go to your user security page.
+
+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 (something like `9ad01c85336b265406fa6554a9a681a4b281135f`).
+ * **Make sure that you click on the "Lock" icon to encrypt and hide this token.**
+
+3. Edit the `bitbucket-pipelines.yml` file of your repository to trigger the SonarCloud analysis.
+
+Once those changes are pushed, Pipelines will automatically trigger analyses on the repository.
+
+You can see our multiple sample projects to see how it is working :
+
+ * [Built with Gradle](https://bitbucket.org/sonarsource/sample-gradle-project)
+ * [Built with Maven](https://bitbucket.org/sonarsource/sample-maven-project)
+ * [Javascript project](https://bitbucket.org/sonarsource/sample-nodejs-project)
+
+If you target a .NET application, see a [sample .NET project](https://bitbucket.org/sonarsource/sample-dotnet-project-azuredevops) built with Azure Pipelines
+
+## Analyzing pull requests
+
+In order to trigger SonarCloud analysis on each pull request update, you have to supply the same command in the `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 sonar:sonar
+ ...
+```
+
+In order to avoid duplication between the different sections of your `bitbucket-pipelines.yml`, you can use [yaml anchors and aliases](https://confluence.atlassian.com/bitbucket/yaml-anchors-960154027.html).
diff --git a/server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud.md b/server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud.md
index b19cdb62fdc..84dde4116bd 100644
--- a/server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud.md
+++ b/server/sonar-docs/src/pages/sonarcloud/integrations/bitbucketcloud.md
@@ -10,35 +10,10 @@ url: /integrations/bitbucketcloud/
3. You will be asked to install the SonarCould application on your team or user account, which will allow you to
choose which repositories you want to analyze.
-## Analyzing with Pipelines
+## Analyzing your repository
-Once your project is created and initiated from the repository you selected:
-
-1. Generate a token to allow to publish analysis from Bitbucket Pipelines. To generate a token, follow the first step of the tutorial on the dashboard of the project, or go to your user security page.
-
-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 (something like `9ad01c85336b265406fa6554a9a681a4b281135f`).
- * **Make sure that you click on the "Lock" icon to encrypt and hide this token.**
-
-3. Edit the `bitbucket-pipelines.yml` file of your repository to trigger the SonarCloud analysis. See [our various example projects](https://bitbucket.org/account/user/sonarsource/projects/SAMPLES) to see how to achieve this.
- * Note: if you did not activate Pipelines prior to this step, you should go to the "Pipelines" menu entry on your repository to enable it.
-
-Once those changes are pushed, Pipelines will automatically trigger analyses on the repository.
-
-## Analyzing pull requests with Pipelines
-
-In order to trigger SonarCloud analysis on each pull request update, you have to supply the same command in the `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 sonar:sonar
- ...
-```
-
-In order to avoid duplication between the different sections of your `bitbucket-pipelines.yml`, you can use [yaml anchors and aliases](https://confluence.atlassian.com/bitbucket/yaml-anchors-960154027.html).
+* [With Bitbucket Pipelines](/integrations/bitbucketcloud/bitbucket-pipelines/)
+* [With Azure Pipelines](/integrations/bitbucketcloud/azure-pipelines/), if you analyze .NET applications and want to benefit from Azure DevOps features.
## Quality widget
diff --git a/server/sonar-web/src/main/js/apps/tutorials/analyzeProject/AnalyzeTutorialSuggestion.tsx b/server/sonar-web/src/main/js/apps/tutorials/analyzeProject/AnalyzeTutorialSuggestion.tsx
index fb2428ad727..4eca0f23f76 100644
--- a/server/sonar-web/src/main/js/apps/tutorials/analyzeProject/AnalyzeTutorialSuggestion.tsx
+++ b/server/sonar-web/src/main/js/apps/tutorials/analyzeProject/AnalyzeTutorialSuggestion.tsx
@@ -27,25 +27,21 @@ import { Alert } from '../../../components/ui/Alert';
export function TutorialSuggestionBitbucket() {
return (
<Alert className="big-spacer-bottom" variant="info">
- <p>{translate('onboarding.project_analysis.commands_for_analysis')}</p>
- <p>{translate('onboarding.project_analysis.suggestions.bitbucket')}</p>
<FormattedMessage
- defaultMessage={translate('onboarding.project_analysis.simply_link')}
- id={'onboarding.project_analysis.simply_link'}
+ defaultMessage={translate('onboarding.project_analysis.suggestions.bitbucket')}
+ id={'onboarding.project_analysis.suggestions.bitbucket'}
values={{
link: (
<a
- href={
- getBaseUrl() +
- '/documentation/integrations/bitbucketcloud/#analyzing-with-pipelines'
- }
+ href={getBaseUrl() + '/documentation/integrations/bitbucketcloud/'}
rel="noopener noreferrer"
target="_blank">
- {translate('onboarding.project_analysis.guide_to_integrate_pipelines')}
+ {translate('onboarding.project_analysis.guide_to_integrate_bitbucket_cloud')}
</a>
)
}}
/>
+ <p>{translate('onboarding.project_analysis.suggestions.bitbucket_extra')}</p>
</Alert>
);
}
diff --git a/server/sonar-web/src/main/js/apps/tutorials/analyzeProject/__tests__/__snapshots__/AnalyzeTutorialSuggestion-test.tsx.snap b/server/sonar-web/src/main/js/apps/tutorials/analyzeProject/__tests__/__snapshots__/AnalyzeTutorialSuggestion-test.tsx.snap
index e89e8e2d821..42c061fdfd5 100644
--- a/server/sonar-web/src/main/js/apps/tutorials/analyzeProject/__tests__/__snapshots__/AnalyzeTutorialSuggestion-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/tutorials/analyzeProject/__tests__/__snapshots__/AnalyzeTutorialSuggestion-test.tsx.snap
@@ -5,27 +5,24 @@ exports[`renders bitbucket tutorial correctly 1`] = `
className="big-spacer-bottom"
variant="info"
>
- <p>
- onboarding.project_analysis.commands_for_analysis
- </p>
- <p>
- onboarding.project_analysis.suggestions.bitbucket
- </p>
<FormattedMessage
- defaultMessage="onboarding.project_analysis.simply_link"
- id="onboarding.project_analysis.simply_link"
+ defaultMessage="onboarding.project_analysis.suggestions.bitbucket"
+ id="onboarding.project_analysis.suggestions.bitbucket"
values={
Object {
"link": <a
- href="/documentation/integrations/bitbucketcloud/#analyzing-with-pipelines"
+ href="/documentation/integrations/bitbucketcloud/"
rel="noopener noreferrer"
target="_blank"
>
- onboarding.project_analysis.guide_to_integrate_pipelines
+ onboarding.project_analysis.guide_to_integrate_bitbucket_cloud
</a>,
}
}
/>
+ <p>
+ onboarding.project_analysis.suggestions.bitbucket_extra
+ </p>
</Alert>
`;
diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
index 9341b22f823..376cf813e17 100644
--- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
@@ -2801,10 +2801,12 @@ onboarding.project_analysis.header=Analyze your project
onboarding.project_analysis.description=We initialized your project on {instance}, now it's up to you to launch analyses!
onboarding.project_analysis.commands_for_analysis=Below are the commands to use to do an analysis.
onboarding.project_analysis.guide_to_integrate_pipelines=follow the guide to integrating with Pipelines
+onboarding.project_analysis.guide_to_integrate_bitbucket_cloud=Get started with Bitbucket Cloud
onboarding.project_analysis.guide_to_integrate_travis=follow the guide to integrating with Travis CI
onboarding.project_analysis.guide_to_integrate_vsts=follow the guide to integrating with Azure DevOps Services
onboarding.project_analysis.simply_link=Simply {link}.
-onboarding.project_analysis.suggestions.bitbucket=If you are using Bitbucket Cloud Pipelines, the SonarCloud App makes it easier to run these commands with your CI process.
+onboarding.project_analysis.suggestions.bitbucket=Please follow the {link} guide to find out how to configure your CI to analyze your repository in a couple of minutes.
+onboarding.project_analysis.suggestions.bitbucket_extra=In case you need it, the steps below will help you find the relevant command to execute in your build script.
onboarding.project_analysis.suggestions.github=If you are using Travis CI, the SonarCloud Travis Add-on makes it easier to run these commands with your CI process.
onboarding.create_project.header=Analyze projects