aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorJeremy Davis <jeremy.davis@sonarsource.com>2021-06-17 11:36:05 +0200
committersonartech <sonartech@sonarsource.com>2021-06-22 20:03:14 +0000
commit89eba1f0622a489e1e0b92316aaeedbd369c187f (patch)
tree2f1d729626b6012efe1b2d1342179374fc318b46 /server/sonar-web
parentcc3cf41cae41403f763103c3a033b269e19ec3a8 (diff)
downloadsonarqube-89eba1f0622a489e1e0b92316aaeedbd369c187f.tar.gz
sonarqube-89eba1f0622a489e1e0b92316aaeedbd369c187f.zip
SONAR-15029 C-Family tutorial for Bitbucket Pipelines
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx156
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/PreambuleYaml.tsx1
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/AnalysisCommand-test.tsx21
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/PreambuleYaml-test.tsx15
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap138
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/PreambuleYaml-test.tsx.snap27
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/CFamily.ts64
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/DotNet.ts64
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Gradle.ts55
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Maven.ts55
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Others.ts55
11 files changed, 490 insertions, 161 deletions
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx
index 84c136e433c..1c53cd067be 100644
--- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx
@@ -20,8 +20,14 @@
import { Dictionary } from 'lodash';
import * as React from 'react';
import { withAppState } from '../../hoc/withAppState';
+import { CompilationInfo } from '../components/CompilationInfo';
import CreateYmlFile from '../components/CreateYmlFile';
import { BuildTools } from '../types';
+import cFamilyExample from './commands/CFamily';
+import dotNetExample from './commands/DotNet';
+import gradleExample from './commands/Gradle';
+import mavenExample from './commands/Maven';
+import othersExample from './commands/Others';
import { PreambuleYaml } from './PreambuleYaml';
export interface AnalysisCommandProps {
@@ -31,150 +37,11 @@ export interface AnalysisCommandProps {
}
const YamlTemplate: Dictionary<(branchesEnabled?: boolean, projectKey?: string) => string> = {
- [BuildTools.Gradle]: branchesEnabled => `image: openjdk:8
-
-clone:
- depth: full
-
-pipelines:
- branches:
- '{master}':
- - step:
- name: SonarQube analysis
- caches:
- - gradle
- - sonar
- script:
- - bash ./gradlew sonarqube
-${
- branchesEnabled
- ? `
- pull-requests:
- '**':
- - step:
- name: SonarQube analysis
- caches:
- - gradle
- - sonar
- script:
- - bash ./gradlew sonarqube
-`
- : ''
-}
-definitions:
- caches:
- sonar: ~/.sonar`,
- [BuildTools.Maven]: branchesEnabled => `image: maven:3.3.9
-
-clone:
- depth: full
-
-pipelines:
- branches:
- '{master}':
- - step:
- name: SonarQube analysis
- caches:
- - maven
- - sonar
- script:
- - mvn verify sonar:sonar
-${
- branchesEnabled
- ? `
- pull-requests:
- '**':
- - step:
- name: SonarQube analysis
- caches:
- - maven
- - sonar
- script:
- - mvn verify sonar:sonar
-`
- : ''
-}
-definitions:
- caches:
- sonar: ~/.sonar`,
- [BuildTools.DotNet]: (
- branchesEnabled,
- projectKey
- ) => `image: mcr.microsoft.com/dotnet/core/sdk:latest
-
-pipelines:
- branches:
- '{master}':
- - step:
- name: SonarQube analysis
- caches:
- - dotnetcore
- - sonar
- script:
- - apt-get update
- - apt-get install --yes openjdk-11-jre
- - dotnet tool install --global dotnet-sonarscanner
- - export PATH="$PATH:/root/.dotnet/tools"
- - dotnet sonarscanner begin /k:"${projectKey}" /d:"sonar.login=\${SONAR_TOKEN}" /d:"sonar.host.url=\${SONAR_HOST_URL}"
- - dotnet build
- - dotnet sonarscanner end /d:"sonar.login=\${SONAR_TOKEN}"
- ${
- branchesEnabled
- ? `
- pull-requests:
- '**':
- - step:
- name: SonarQube analysis
- caches:
- - dotnetcore
- - sonar
- script:
- - apt-get update
- - apt-get install --yes openjdk-11-jre
- - dotnet tool install --global dotnet-sonarscanner
- - export PATH="$PATH:/root/.dotnet/tools"
- - dotnet sonarscanner begin /k:"${projectKey}" /d:"sonar.login=\${SONAR_TOKEN}" /d:"sonar.host.url=\${SONAR_HOST_URL}"
- - dotnet build
- - dotnet sonarscanner end /d:"sonar.login=\${SONAR_TOKEN}"
- `
- : ''
- }
-definitions:
- caches:
- sonar: ~/.sonar`,
- [BuildTools.Other]: branchesEnabled => `image: maven:3.3.9
-
-clone:
- depth: full
-
-pipelines:
- branches:
- '{master}':
- - step:
- name: SonarQube analysis
- script:
- - pipe: sonarsource/sonarqube-scan:1.0.0
- variables:
- SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable.
- SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here.
-${
- branchesEnabled
- ? `
- pull-requests:
- '**':
- - step:
- name: SonarQube analysis
- script:
- - pipe: sonarsource/sonarqube-scan:1.0.0
- variables:
- SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable.
- SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here.
-`
- : ''
-}
-definitions:
- caches:
- sonar: ~/.sonar`
+ [BuildTools.Gradle]: gradleExample,
+ [BuildTools.Maven]: mavenExample,
+ [BuildTools.DotNet]: dotNetExample,
+ [BuildTools.CFamily]: cFamilyExample,
+ [BuildTools.Other]: othersExample
};
export function AnalysisCommand(props: AnalysisCommandProps) {
@@ -194,6 +61,7 @@ export function AnalysisCommand(props: AnalysisCommandProps) {
<>
<PreambuleYaml buildTool={buildTool} component={component} />
<CreateYmlFile yamlFileName="bitbucket-pipelines.yml" yamlTemplate={yamlTemplate} />
+ {buildTool === BuildTools.CFamily && <CompilationInfo className="abs-width-800" />}
</>
);
}
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/PreambuleYaml.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/PreambuleYaml.tsx
index f27c17e23d5..910cfa3034c 100644
--- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/PreambuleYaml.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/PreambuleYaml.tsx
@@ -71,6 +71,7 @@ export function PreambuleYaml(props: PreambuleYamlProps) {
<CodeSnippet snippet={mavenPomSnippet(component.key)} />
</li>
);
+ case BuildTools.CFamily:
case BuildTools.Other:
return <DefaultProjectKey component={component} />;
default:
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/AnalysisCommand-test.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/AnalysisCommand-test.tsx
index fe163ec5ba7..ff047ac097e 100644
--- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/AnalysisCommand-test.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/AnalysisCommand-test.tsx
@@ -23,15 +23,18 @@ import { mockAppState, mockComponent } from '../../../../helpers/testMocks';
import { BuildTools } from '../../types';
import { AnalysisCommand, AnalysisCommandProps } from '../AnalysisCommand';
-it.each([[BuildTools.DotNet], [BuildTools.Gradle], [BuildTools.Maven], [BuildTools.Other]])(
- 'should render correctly for %s',
- buildTool => {
- expect(shallowRender({ buildTool })).toMatchSnapshot();
- expect(
- shallowRender({ appState: mockAppState({ branchesEnabled: true }), buildTool })
- ).toMatchSnapshot('with branch enabled');
- }
-);
+it.each([
+ [BuildTools.CFamily],
+ [BuildTools.DotNet],
+ [BuildTools.Gradle],
+ [BuildTools.Maven],
+ [BuildTools.Other]
+])('should render correctly for %s', buildTool => {
+ expect(shallowRender({ buildTool })).toMatchSnapshot();
+ expect(
+ shallowRender({ appState: mockAppState({ branchesEnabled: true }), buildTool })
+ ).toMatchSnapshot('with branch enabled');
+});
function shallowRender(props: Partial<AnalysisCommandProps> = {}) {
return shallow<AnalysisCommandProps>(
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/PreambuleYaml-test.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/PreambuleYaml-test.tsx
index c8c5a5248c2..bf5057ade16 100644
--- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/PreambuleYaml-test.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/PreambuleYaml-test.tsx
@@ -23,12 +23,15 @@ import { mockComponent } from '../../../../helpers/testMocks';
import { BuildTools } from '../../types';
import { PreambuleYaml, PreambuleYamlProps } from '../PreambuleYaml';
-it.each([[BuildTools.DotNet], [BuildTools.Gradle], [BuildTools.Maven], [BuildTools.Other]])(
- 'should render correctly for %s',
- buildTool => {
- expect(shallowRender({ buildTool })).toMatchSnapshot();
- }
-);
+it.each([
+ [BuildTools.DotNet],
+ [BuildTools.Gradle],
+ [BuildTools.Maven],
+ [BuildTools.CFamily],
+ [BuildTools.Other]
+])('should render correctly for %s', buildTool => {
+ expect(shallowRender({ buildTool })).toMatchSnapshot();
+});
function shallowRender(props: Partial<PreambuleYamlProps> = {}) {
return shallow<PreambuleYamlProps>(
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap
index 51a6080106e..fee8cfa96ea 100644
--- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap
@@ -1,5 +1,139 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`should render correctly for cfamily 1`] = `
+<Fragment>
+ <PreambuleYaml
+ buildTool="cfamily"
+ component={
+ Object {
+ "breadcrumbs": Array [],
+ "key": "my-project",
+ "name": "MyProject",
+ "qualifier": "TRK",
+ "qualityGate": Object {
+ "isDefault": true,
+ "key": "30",
+ "name": "Sonar way",
+ },
+ "qualityProfiles": Array [
+ Object {
+ "deleted": false,
+ "key": "my-qp",
+ "language": "ts",
+ "name": "Sonar way",
+ },
+ ],
+ "tags": Array [],
+ }
+ }
+ />
+ <CreateYmlFile
+ yamlFileName="bitbucket-pipelines.yml"
+ yamlTemplate="image: <image ready for your build toolchain>
+
+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}
+
+definitions:
+ caches:
+ sonar: ~/.sonar"
+ />
+ <CompilationInfo
+ className="abs-width-800"
+ />
+</Fragment>
+`;
+
+exports[`should render correctly for cfamily: with branch enabled 1`] = `
+<Fragment>
+ <PreambuleYaml
+ buildTool="cfamily"
+ component={
+ Object {
+ "breadcrumbs": Array [],
+ "key": "my-project",
+ "name": "MyProject",
+ "qualifier": "TRK",
+ "qualityGate": Object {
+ "isDefault": true,
+ "key": "30",
+ "name": "Sonar way",
+ },
+ "qualityProfiles": Array [
+ Object {
+ "deleted": false,
+ "key": "my-qp",
+ "language": "ts",
+ "name": "Sonar way",
+ },
+ ],
+ "tags": Array [],
+ }
+ }
+ />
+ <CreateYmlFile
+ yamlFileName="bitbucket-pipelines.yml"
+ yamlTemplate="image: <image ready for your build toolchain>
+
+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}
+definitions:
+ caches:
+ sonar: ~/.sonar"
+ />
+ <CompilationInfo
+ className="abs-width-800"
+ />
+</Fragment>
+`;
+
exports[`should render correctly for dotnet 1`] = `
<Fragment>
<PreambuleYaml
@@ -30,7 +164,7 @@ exports[`should render correctly for dotnet 1`] = `
<CreateYmlFile
yamlFileName="bitbucket-pipelines.yml"
yamlTemplate="image: mcr.microsoft.com/dotnet/core/sdk:latest
-
+
pipelines:
branches:
'{master}':
@@ -85,7 +219,7 @@ exports[`should render correctly for dotnet: with branch enabled 1`] = `
<CreateYmlFile
yamlFileName="bitbucket-pipelines.yml"
yamlTemplate="image: mcr.microsoft.com/dotnet/core/sdk:latest
-
+
pipelines:
branches:
'{master}':
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/PreambuleYaml-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/PreambuleYaml-test.tsx.snap
index 83b893d71dc..c83e2df55e2 100644
--- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/PreambuleYaml-test.tsx.snap
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/PreambuleYaml-test.tsx.snap
@@ -1,5 +1,32 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`should render correctly for cfamily 1`] = `
+<DefaultProjectKey
+ component={
+ Object {
+ "breadcrumbs": Array [],
+ "key": "my-project",
+ "name": "MyProject",
+ "qualifier": "TRK",
+ "qualityGate": Object {
+ "isDefault": true,
+ "key": "30",
+ "name": "Sonar way",
+ },
+ "qualityProfiles": Array [
+ Object {
+ "deleted": false,
+ "key": "my-qp",
+ "language": "ts",
+ "name": "Sonar way",
+ },
+ ],
+ "tags": Array [],
+ }
+ }
+/>
+`;
+
exports[`should render correctly for dotnet 1`] = `""`;
exports[`should render correctly for gradle 1`] = `
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/CFamily.ts b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/CFamily.ts
new file mode 100644
index 00000000000..87f30846c4e
--- /dev/null
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/CFamily.ts
@@ -0,0 +1,64 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+export default function cFamilyExample(branchesEnabled: boolean) {
+ return `image: <image ready for your build toolchain>
+
+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}
+${
+ branchesEnabled
+ ? `
+ 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}`
+ : ''
+}
+definitions:
+ caches:
+ sonar: ~/.sonar`;
+}
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/DotNet.ts b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/DotNet.ts
new file mode 100644
index 00000000000..ec1c82fdd11
--- /dev/null
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/DotNet.ts
@@ -0,0 +1,64 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+export default function dotNetExample(branchesEnabled: boolean, projectKey: string) {
+ return `image: mcr.microsoft.com/dotnet/core/sdk:latest
+
+pipelines:
+ branches:
+ '{master}':
+ - step:
+ name: SonarQube analysis
+ caches:
+ - dotnetcore
+ - sonar
+ script:
+ - apt-get update
+ - apt-get install --yes openjdk-11-jre
+ - dotnet tool install --global dotnet-sonarscanner
+ - export PATH="$PATH:/root/.dotnet/tools"
+ - dotnet sonarscanner begin /k:"${projectKey}" /d:"sonar.login=\${SONAR_TOKEN}" /d:"sonar.host.url=\${SONAR_HOST_URL}"
+ - dotnet build
+ - dotnet sonarscanner end /d:"sonar.login=\${SONAR_TOKEN}"
+ ${
+ branchesEnabled
+ ? `
+ pull-requests:
+ '**':
+ - step:
+ name: SonarQube analysis
+ caches:
+ - dotnetcore
+ - sonar
+ script:
+ - apt-get update
+ - apt-get install --yes openjdk-11-jre
+ - dotnet tool install --global dotnet-sonarscanner
+ - export PATH="$PATH:/root/.dotnet/tools"
+ - dotnet sonarscanner begin /k:"${projectKey}" /d:"sonar.login=\${SONAR_TOKEN}" /d:"sonar.host.url=\${SONAR_HOST_URL}"
+ - dotnet build
+ - dotnet sonarscanner end /d:"sonar.login=\${SONAR_TOKEN}"
+ `
+ : ''
+ }
+definitions:
+ caches:
+ sonar: ~/.sonar`;
+}
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Gradle.ts b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Gradle.ts
new file mode 100644
index 00000000000..78d5bc4c86b
--- /dev/null
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Gradle.ts
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+export default function gradleExample(branchesEnabled: boolean) {
+ return `image: openjdk:8
+
+clone:
+ depth: full
+
+pipelines:
+ branches:
+ '{master}':
+ - step:
+ name: SonarQube analysis
+ caches:
+ - gradle
+ - sonar
+ script:
+ - bash ./gradlew sonarqube
+${
+ branchesEnabled
+ ? `
+ pull-requests:
+ '**':
+ - step:
+ name: SonarQube analysis
+ caches:
+ - gradle
+ - sonar
+ script:
+ - bash ./gradlew sonarqube
+`
+ : ''
+}
+definitions:
+ caches:
+ sonar: ~/.sonar`;
+}
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Maven.ts b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Maven.ts
new file mode 100644
index 00000000000..7cc04a84a06
--- /dev/null
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Maven.ts
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+export default function mavenExample(branchesEnabled: boolean) {
+ return `image: maven:3.3.9
+
+clone:
+ depth: full
+
+pipelines:
+ branches:
+ '{master}':
+ - step:
+ name: SonarQube analysis
+ caches:
+ - maven
+ - sonar
+ script:
+ - mvn verify sonar:sonar
+${
+ branchesEnabled
+ ? `
+ pull-requests:
+ '**':
+ - step:
+ name: SonarQube analysis
+ caches:
+ - maven
+ - sonar
+ script:
+ - mvn verify sonar:sonar
+`
+ : ''
+}
+definitions:
+ caches:
+ sonar: ~/.sonar`;
+}
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Others.ts b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Others.ts
new file mode 100644
index 00000000000..b3e147b98d6
--- /dev/null
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Others.ts
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2021 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+export default function othersExample(branchesEnabled: boolean) {
+ return `image: maven:3.3.9
+
+clone:
+ depth: full
+
+pipelines:
+ branches:
+ '{master}':
+ - step:
+ name: SonarQube analysis
+ script:
+ - pipe: sonarsource/sonarqube-scan:1.0.0
+ variables:
+ SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable.
+ SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here.
+${
+ branchesEnabled
+ ? `
+ pull-requests:
+ '**':
+ - step:
+ name: SonarQube analysis
+ script:
+ - pipe: sonarsource/sonarqube-scan:1.0.0
+ variables:
+ SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable.
+ SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here.
+`
+ : ''
+}
+definitions:
+ caches:
+ sonar: ~/.sonar`;
+}