]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-15029 C-Family tutorial for Bitbucket Pipelines
authorJeremy Davis <jeremy.davis@sonarsource.com>
Thu, 17 Jun 2021 09:36:05 +0000 (11:36 +0200)
committersonartech <sonartech@sonarsource.com>
Tue, 22 Jun 2021 20:03:14 +0000 (20:03 +0000)
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/PreambuleYaml.tsx
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/AnalysisCommand-test.tsx
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/PreambuleYaml-test.tsx
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/PreambuleYaml-test.tsx.snap
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/CFamily.ts [new file with mode: 0644]
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/DotNet.ts [new file with mode: 0644]
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Gradle.ts [new file with mode: 0644]
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Maven.ts [new file with mode: 0644]
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Others.ts [new file with mode: 0644]

index 84c136e433c85604cbf66b4b7e81105233233a8d..1c53cd067bed8d72f840e30770514284dd77875a 100644 (file)
 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" />}
     </>
   );
 }
index f27c17e23d58eb5832bcb34709a0ab293b233a93..910cfa3034c22c8a54aeb6df366027e7693d1940 100644 (file)
@@ -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:
index fe163ec5ba77546bc0e3d031bd64ab336bc830c7..ff047ac097e9d46201770694133f94b67dc83460 100644 (file)
@@ -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>(
index c8c5a5248c29a50822ca525073795a948ef6d492..bf5057ade16d360b671b1799997a1edd3ff49333 100644 (file)
@@ -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>(
index 51a6080106e25a9fcf2a2bab53135ec375ec6874..fee8cfa96eaf9351a0ea9ac17c7dc7c529623a73 100644 (file)
@@ -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}':
index 83b893d71dcd34fc7336d9cd39a788bb1fb724d9..c83e2df55e26e15811057fb03c157a5c8aba706e 100644 (file)
@@ -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 (file)
index 0000000..87f3084
--- /dev/null
@@ -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 (file)
index 0000000..ec1c82f
--- /dev/null
@@ -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 (file)
index 0000000..78d5bc4
--- /dev/null
@@ -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 (file)
index 0000000..7cc04a8
--- /dev/null
@@ -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 (file)
index 0000000..b3e147b
--- /dev/null
@@ -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`;
+}