]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-17528 Update Bitbucket pipeline tutorial
authorGuillaume Peoc'h <guillaume.peoch@sonarsource.com>
Mon, 31 Oct 2022 16:35:30 +0000 (17:35 +0100)
committersonartech <sonartech@sonarsource.com>
Tue, 1 Nov 2022 20:03:09 +0000 (20:03 +0000)
server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.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__/BitbucketPipelinesTutorial-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/commands/CFamily.ts
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/DotNet.ts
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Gradle.ts
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Maven.ts
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/Others.ts

index fdaaeacad270ecba682a5379623ede079a966516..6a08e5436465baf5483b23e9b682c3825db3fd0f 100644 (file)
@@ -224,6 +224,7 @@ export default function TutorialSelectionRenderer(props: TutorialSelectionRender
           baseUrl={baseUrl}
           component={component}
           currentUser={currentUser}
+          mainBranchName={mainBranchName}
           projectBinding={projectBinding}
           willRefreshAutomatically={willRefreshAutomatically}
         />
index cc8586626c76a8241abd0645dfc96c333c9950ca..b29b219c0f552589c2920134bed655c55c3329a7 100644 (file)
@@ -36,10 +36,15 @@ import { PreambuleYaml } from './PreambuleYaml';
 
 export interface AnalysisCommandProps extends WithAvailableFeaturesProps {
   buildTool: BuildTools;
+  mainBranchName: string;
   component: Component;
 }
 
-const YamlTemplate: Dictionary<(branchesEnabled?: boolean, projectKey?: string) => string> = {
+const YamlTemplate: Dictionary<(
+  branchesEnabled?: boolean,
+  mainBranchName?: string,
+  projectKey?: string
+) => string> = {
   [BuildTools.Gradle]: gradleExample,
   [BuildTools.Maven]: mavenExample,
   [BuildTools.DotNet]: dotNetExample,
@@ -48,14 +53,14 @@ const YamlTemplate: Dictionary<(branchesEnabled?: boolean, projectKey?: string)
 };
 
 export function AnalysisCommand(props: AnalysisCommandProps) {
-  const { buildTool, component } = props;
+  const { buildTool, mainBranchName, component } = props;
   const branchSupportEnabled = props.hasFeature(Feature.BranchSupport);
 
   if (!buildTool) {
     return null;
   }
 
-  const yamlTemplate = YamlTemplate[buildTool](branchSupportEnabled, component.key);
+  const yamlTemplate = YamlTemplate[buildTool](branchSupportEnabled, mainBranchName, component.key);
 
   return (
     <>
index 2ac61ddcf7990dfc382f35562f3c439807fed6ba..dfaee042ab78f2ba7f5f3094426f7accb18902fb 100644 (file)
@@ -46,6 +46,7 @@ export interface BitbucketPipelinesTutorialProps {
   baseUrl: string;
   component: Component;
   currentUser: LoggedInUser;
+  mainBranchName: string;
   projectBinding?: ProjectAlmBindingResponse;
   willRefreshAutomatically?: boolean;
 }
@@ -57,7 +58,8 @@ export default function BitbucketPipelinesTutorial(props: BitbucketPipelinesTuto
     currentUser,
     component,
     projectBinding,
-    willRefreshAutomatically
+    willRefreshAutomatically,
+    mainBranchName
   } = props;
 
   const [step, setStep] = React.useState<Steps>(Steps.REPOSITORY_VARIABLES);
@@ -94,7 +96,11 @@ export default function BitbucketPipelinesTutorial(props: BitbucketPipelinesTuto
                     ci={TutorialModes.BitbucketPipelines}
                   />
                 )}
-                <AnalysisCommand buildTool={buildTool} component={component} />
+                <AnalysisCommand
+                  buildTool={buildTool}
+                  component={component}
+                  mainBranchName={mainBranchName}
+                />
                 <FinishButton onClick={() => setStep(Steps.ALL_SET)} />
               </>
             )}
index a3f9602d9ff03de8c5d6334851fa7bc1683c6bb8..50253295ec26bba1216bb18a7b92fe66ca02757c 100644 (file)
@@ -41,6 +41,7 @@ function shallowRender(props: Partial<AnalysisCommandProps> = {}) {
     <AnalysisCommand
       hasFeature={jest.fn().mockReturnValue(false)}
       buildTool={BuildTools.DotNet}
+      mainBranchName="main"
       component={mockComponent()}
       {...props}
     />
index 96786af707e066eae3a5249e87bc1d3f6a8c2a7a..11c2961ddb918e64993581479fed96724ca271f0 100644 (file)
@@ -77,6 +77,7 @@ function shallowRender(props: Partial<BitbucketPipelinesTutorialProps> = {}) {
     <BitbucketPipelinesTutorial
       almBinding={mockAlmSettingsInstance()}
       baseUrl="test"
+      mainBranchName="main"
       currentUser={mockLoggedInUser()}
       component={mockComponent()}
       projectBinding={mockProjectBitbucketCloudBindingResponse()}
index 6a24055c89b5e8b55f61fa54d9805c273884ed95..c1c0ee6a435af3c1a82071476f73608b677013e8 100644 (file)
@@ -54,7 +54,7 @@ clone:
 
 pipelines:
   branches:
-    '{master}': # or the name of your main branch
+    '{main}':
       - step: *build-step
 "
   />
@@ -118,7 +118,7 @@ clone:
 
 pipelines:
   branches:
-    '{master}': # or the name of your main branch
+    '{main}':
       - step: *build-step
 
   pull-requests:
@@ -182,7 +182,7 @@ definitions:
 
 pipelines:
   branches:
-    '{master}': # or the name of your main branch
+    '{main}':
       - step: *build-step
 "
   />
@@ -240,7 +240,7 @@ definitions:
 
 pipelines:
   branches:
-    '{master}': # or the name of your main branch
+    '{main}':
       - step: *build-step
 
   pull-requests:
@@ -298,7 +298,7 @@ clone:
   
 pipelines:
   branches:
-    '{master}': # or the name of your main branch
+    '{main}':
       - step: *build-step
 "
   />
@@ -353,7 +353,7 @@ clone:
   
 pipelines:
   branches:
-    '{master}': # or the name of your main branch
+    '{main}':
       - step: *build-step
 
   pull-requests:
@@ -411,7 +411,7 @@ clone:
   
 pipelines:
   branches:
-    '{master}': # or the name of your main branch
+    '{main}':
       - step: *build-step
 "
   />
@@ -466,7 +466,7 @@ clone:
   
 pipelines:
   branches:
-    '{master}': # or the name of your main branch
+    '{main}':
       - step: *build-step
 
   pull-requests:
@@ -524,7 +524,7 @@ clone:
 
 pipelines:
   branches:
-    '{master}': # or the name of your main branch
+    '{main}':
       - step: *build-step
 "
   />
@@ -579,7 +579,7 @@ clone:
 
 pipelines:
   branches:
-    '{master}': # or the name of your main branch
+    '{main}':
       - step: *build-step
 
   pull-requests:
index ddc90185387c6137044ae8789363c7993313c38b..ca6834e08c6006ff67b62039a3220ef2fd441722 100644 (file)
@@ -17,7 +17,7 @@
  * 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) {
+export default function cFamilyExample(branchesEnabled: boolean, mainBranchName: string) {
   return `image: <image ready for your build toolchain>
 
 definitions:
@@ -43,7 +43,7 @@ clone:
 
 pipelines:
   branches:
-    '{master}': # or the name of your main branch
+    '{${mainBranchName}}':
       - step: *build-step
 ${
   branchesEnabled
index dfb9d606d8661d989e1de6380494c53b3a2ed273..a3cc6f5b03e73f87884fa5bd442ceaa122fde07a 100644 (file)
  * 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) {
+export default function dotNetExample(
+  branchesEnabled: boolean,
+  mainBranchName: string,
+  projectKey: string
+) {
   return `image: mcr.microsoft.com/dotnet/core/sdk:latest
 
 definitions:
@@ -40,7 +44,7 @@ definitions:
 
 pipelines:
   branches:
-    '{master}': # or the name of your main branch
+    '{${mainBranchName}}':
       - step: *build-step
 ${
   branchesEnabled
index 528239dd258cc8376bdd41e5c837ca6a75078e1d..cedaa641248c43c1885a123b0ea1f7ce5e45ea97 100644 (file)
@@ -17,7 +17,7 @@
  * 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) {
+export default function gradleExample(branchesEnabled: boolean, mainBranchName: string) {
   return `image: openjdk:8
 
 definitions:
@@ -37,7 +37,7 @@ clone:
   
 pipelines:
   branches:
-    '{master}': # or the name of your main branch
+    '{${mainBranchName}}':
       - step: *build-step
 ${
   branchesEnabled
index c38266b6cc70393aaae7d981ba5c21a53dd22e60..20b2f952a413fab9dd812a9b965dbf5416032a8c 100644 (file)
  * 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, projectKey: string) {
+export default function mavenExample(
+  branchesEnabled: boolean,
+  mainBranchName: string,
+  projectKey: string
+) {
   return `image: maven:3-openjdk-11
 
 definitions:
@@ -37,7 +41,7 @@ clone:
   
 pipelines:
   branches:
-    '{master}': # or the name of your main branch
+    '{${mainBranchName}}':
       - step: *build-step
 ${
   branchesEnabled
index 16f5a21431989035d07edf7c3b63d0fffaee3f89..ddabc30f87624663f4fd2b488be7c2100eaa0244 100644 (file)
@@ -17,7 +17,7 @@
  * 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) {
+export default function othersExample(branchesEnabled: boolean, mainBranchName: string) {
   return `image: maven:3.3.9
 
 definitions:
@@ -37,7 +37,7 @@ clone:
 
 pipelines:
   branches:
-    '{master}': # or the name of your main branch
+    '{${mainBranchName}}':
       - step: *build-step
 ${
   branchesEnabled