diff options
author | Guillaume Peoc'h <guillaume.peoch@sonarsource.com> | 2022-10-31 17:35:30 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-11-01 20:03:09 +0000 |
commit | 493b522f0ac52122ace3fa12fa5d53e823b3cb20 (patch) | |
tree | b3ede0b1dfd623f99e8ea5f6a920182860f36ad7 /server/sonar-web/src/main/js | |
parent | ef563f2a2e98629a8be54164e43095d672762c3c (diff) | |
download | sonarqube-493b522f0ac52122ace3fa12fa5d53e823b3cb20.tar.gz sonarqube-493b522f0ac52122ace3fa12fa5d53e823b3cb20.zip |
SONAR-17528 Update Bitbucket pipeline tutorial
Diffstat (limited to 'server/sonar-web/src/main/js')
11 files changed, 47 insertions, 25 deletions
diff --git a/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx b/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx index fdaaeacad27..6a08e543646 100644 --- a/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx @@ -224,6 +224,7 @@ export default function TutorialSelectionRenderer(props: TutorialSelectionRender baseUrl={baseUrl} component={component} currentUser={currentUser} + mainBranchName={mainBranchName} projectBinding={projectBinding} willRefreshAutomatically={willRefreshAutomatically} /> 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 cc8586626c7..b29b219c0f5 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 @@ -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 ( <> diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx index 2ac61ddcf79..dfaee042ab7 100644 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx @@ -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)} /> </> )} 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 a3f9602d9ff..50253295ec2 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 @@ -41,6 +41,7 @@ function shallowRender(props: Partial<AnalysisCommandProps> = {}) { <AnalysisCommand hasFeature={jest.fn().mockReturnValue(false)} buildTool={BuildTools.DotNet} + mainBranchName="main" component={mockComponent()} {...props} /> diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-test.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-test.tsx index 96786af707e..11c2961ddb9 100644 --- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-test.tsx @@ -77,6 +77,7 @@ function shallowRender(props: Partial<BitbucketPipelinesTutorialProps> = {}) { <BitbucketPipelinesTutorial almBinding={mockAlmSettingsInstance()} baseUrl="test" + mainBranchName="main" currentUser={mockLoggedInUser()} component={mockComponent()} projectBinding={mockProjectBitbucketCloudBindingResponse()} 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 6a24055c89b..c1c0ee6a435 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 @@ -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: 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 index ddc90185387..ca6834e08c6 100644 --- 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 @@ -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 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 index dfb9d606d86..a3cc6f5b03e 100644 --- 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 @@ -17,7 +17,11 @@ * 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 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 index 528239dd258..cedaa641248 100644 --- 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 @@ -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 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 index c38266b6cc7..20b2f952a41 100644 --- 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 @@ -17,7 +17,11 @@ * 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 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 index 16f5a214319..ddabc30f876 100644 --- 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 @@ -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 |