diff options
author | Mathieu Suen <mathieu.suen@sonarsource.com> | 2021-02-24 17:38:02 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-03-03 20:12:52 +0000 |
commit | b385d43a605ab10eee767c868eb14ca32cb215a2 (patch) | |
tree | 45b36f6db5c508929ff23f3399a01af127ecf00c | |
parent | 926932fc656afbb49f1cd2c26363cb120a4d7f39 (diff) | |
download | sonarqube-b385d43a605ab10eee767c868eb14ca32cb215a2.tar.gz sonarqube-b385d43a605ab10eee767c868eb14ca32cb215a2.zip |
SONAR-14493 Add tutorial for .NET Core in Jenkins.
19 files changed, 699 insertions, 197 deletions
diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsfileStep.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsfileStep.tsx index f80804519e8..576463cf716 100644 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsfileStep.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsfileStep.tsx @@ -69,7 +69,7 @@ export function JenkinsfileStep(props: JenkinsfileStepProps) { name="buildtool" onCheck={value => setBuildTool(value as BuildToolsWithoutCFamily)} optionLabelKey="onboarding.build" - options={Object.values(BuildTools)} + options={Object.keys(BUILDTOOL_COMPONENT_MAP)} /> </li> {buildTool !== undefined && diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsfileStep-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsfileStep-test.tsx.snap index 7f2f1394a90..a4610804993 100644 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsfileStep-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsfileStep-test.tsx.snap @@ -18,7 +18,6 @@ exports[`should render correctly for .NET 1`] = ` Array [ "maven", "gradle", - "cfamily", "dotnet", "other", ] @@ -140,7 +139,6 @@ exports[`should render correctly for Gradle 1`] = ` Array [ "maven", "gradle", - "cfamily", "dotnet", "other", ] @@ -262,7 +260,6 @@ exports[`should render correctly for Maven 1`] = ` Array [ "maven", "gradle", - "cfamily", "dotnet", "other", ] @@ -384,7 +381,6 @@ exports[`should render correctly for Other 1`] = ` Array [ "maven", "gradle", - "cfamily", "dotnet", "other", ] @@ -506,7 +502,6 @@ exports[`should render correctly with no branches 1`] = ` Array [ "maven", "gradle", - "cfamily", "dotnet", "other", ] @@ -637,7 +632,6 @@ exports[`should render correctly: initial content 1`] = ` Array [ "maven", "gradle", - "cfamily", "dotnet", "other", ] diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNet.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNet.tsx index 37bf69b928a..413536eda21 100644 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNet.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNet.tsx @@ -18,73 +18,48 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import HelpTooltip from 'sonar-ui-common/components/controls/HelpTooltip'; -import { Alert } from 'sonar-ui-common/components/ui/Alert'; -import CodeSnippet from '../../../common/CodeSnippet'; -import SentenceWithFilename from '../../components/SentenceWithFilename'; -import SentenceWithHighlights from '../../components/SentenceWithHighlights'; +import { translate } from 'sonar-ui-common/helpers/l10n'; +import RenderOptions from '../../components/RenderOptions'; +import { OSs } from '../../types'; +import DotNetCore from './DotNetCore'; +import DotNetFramework from './DotNetFramework'; export interface DotNetProps { component: T.Component; } -const jenkinsfileSnippet = (key: string) => `node { - stage('SCM') { - checkout scm - } - stage('SonarQube Analysis') { - def msbuildHome = tool 'Default MSBuild' - def scannerHome = tool 'SonarScanner for MSBuild' - withSonarQubeEnv() { - bat "\\"\${scannerHome}\\\\SonarScanner.MSBuild.exe\\" begin /k:\\"${key}\\"" - bat "\\"\${msbuildHome}\\\\MSBuild.exe\\" /t:Rebuild" - bat "\\"\${scannerHome}\\\\SonarScanner.MSBuild.exe\\" end" - } - } +export interface DotNetCoreFrameworkProps { + component: T.Component; + os: OSDotNet; } -`; + +export type OSDotNet = OSs.Linux | OSs.Windows; + +const DotNetFlavor = { win_core: DotNetCore, win_msbuild: DotNetFramework, linux_core: DotNetCore }; +const DotOS: { [key in keyof typeof DotNetFlavor]: OSDotNet } = { + win_core: OSs.Windows, + win_msbuild: OSs.Windows, + linux_core: OSs.Linux +}; export default function DotNet({ component }: DotNetProps) { + const [flavorComponent, setFlavorComponet] = React.useState<keyof typeof DotNetFlavor>(); + const DotNetTutorial = flavorComponent && DotNetFlavor[flavorComponent]; return ( - <li className="abs-width-600"> - <SentenceWithFilename - filename="Jenkinsfile" - translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.jenkinsfile_step" - /> - <Alert className="spacer-top" variant="info"> - <p className="text-middle"> - <SentenceWithHighlights - highlightKeys={['default_msbuild', 'default_scanner', 'in_jenkins']} - translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.replace" - /> - <HelpTooltip - className="little-spacer-left" - overlay={ - <> - <p className="spacer-bottom"> - <SentenceWithHighlights - highlightKeys={['path']} - translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help1" - /> - </p> - <p className="spacer-bottom"> - <SentenceWithHighlights - highlightKeys={['path', 'name']} - translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help2" - /> - </p> - <p> - <SentenceWithHighlights - highlightKeys={['path', 'name']} - translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help3" - /> - </p> - </> - } - /> - </p> - </Alert> - <CodeSnippet snippet={jenkinsfileSnippet(component.key)} /> - </li> + <> + <li> + {translate('onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.build_agent')} + <RenderOptions + checked={flavorComponent} + name="flavorComponent" + optionLabelKey="onboarding.build.dotnet" + onCheck={value => setFlavorComponet(value as keyof typeof DotNetFlavor)} + options={Object.keys(DotNetFlavor)} + /> + </li> + {DotNetTutorial && flavorComponent && ( + <DotNetTutorial component={component} os={DotOS[flavorComponent]} /> + )} + </> ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNetCore.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNetCore.tsx new file mode 100644 index 00000000000..f12da8349f4 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNetCore.tsx @@ -0,0 +1,60 @@ +/* + * 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. + */ +import * as React from 'react'; +import CodeSnippet from '../../../common/CodeSnippet'; +import SentenceWithFilename from '../../components/SentenceWithFilename'; +import { OSs } from '../../types'; +import { DotNetCoreFrameworkProps, OSDotNet } from './DotNet'; +import DotNetPrereqsScanner from './DotNetPrereqsScanner'; + +const OSS_DEP: { [key in OSDotNet]: { shell: string; pathSeparator: string } } = { + [OSs.Linux]: { shell: 'sh', pathSeparator: '/' }, + [OSs.Windows]: { shell: 'bat', pathSeparator: '\\\\' } +}; + +const jenkinsfileSnippet = (key: string, shell: OSDotNet) => `node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + ${OSS_DEP[shell].shell} "dotnet \${scannerHome}${OSS_DEP[shell].pathSeparator}SonarScanner.MSBuild.dll begin /k:\\"${key}\\"" + ${OSS_DEP[shell].shell} "dotnet build" + ${OSS_DEP[shell].shell} "dotnet \${scannerHome}${OSS_DEP[shell].pathSeparator}SonarScanner.MSBuild.dll end" + } + } +} +`; + +export default function DotNetCore({ component, os }: DotNetCoreFrameworkProps) { + return ( + <> + <DotNetPrereqsScanner /> + <li className="abs-width-600"> + <SentenceWithFilename + filename="Jenkinsfile" + translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.jenkinsfile_step" + /> + <CodeSnippet snippet={jenkinsfileSnippet(component.key, os)} /> + </li> + </> + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNetFramework.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNetFramework.tsx new file mode 100644 index 00000000000..657476367f5 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNetFramework.tsx @@ -0,0 +1,57 @@ +/* + * 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. + */ +import * as React from 'react'; +import CodeSnippet from '../../../common/CodeSnippet'; +import SentenceWithFilename from '../../components/SentenceWithFilename'; +import { DotNetCoreFrameworkProps } from './DotNet'; +import DotNetPrereqsMSBuild from './DotNetPrereqsMSBuild'; +import DotNetPrereqsScanner from './DotNetPrereqsScanner'; + +const jenkinsfileSnippet = (key: string) => `node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def msbuildHome = tool 'Default MSBuild' + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + bat "\\"\${scannerHome}\\\\SonarScanner.MSBuild.exe\\" begin /k:\\"${key}\\"" + bat "\\"\${msbuildHome}\\\\MSBuild.exe\\" /t:Rebuild" + bat "\\"\${scannerHome}\\\\SonarScanner.MSBuild.exe\\" end" + } + } +} +`; + +export default function DotNetFramework({ component }: DotNetCoreFrameworkProps) { + return ( + <> + <DotNetPrereqsScanner /> + <DotNetPrereqsMSBuild /> + <li className="abs-width-600"> + <SentenceWithFilename + filename="Jenkinsfile" + translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.jenkinsfile_step" + /> + <CodeSnippet snippet={jenkinsfileSnippet(component.key)} /> + </li> + </> + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNetPrereqsMSBuild.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNetPrereqsMSBuild.tsx new file mode 100644 index 00000000000..9a64daa0414 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNetPrereqsMSBuild.tsx @@ -0,0 +1,60 @@ +/* + * 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. + */ +import * as React from 'react'; +import { ClipboardIconButton } from 'sonar-ui-common/components/controls/clipboard'; +import { Alert } from 'sonar-ui-common/components/ui/Alert'; +import { translate } from 'sonar-ui-common/helpers/l10n'; +import SentenceWithHighlights from '../../components/SentenceWithHighlights'; + +export default function DotNetPrereqsMSBuild() { + return ( + <li className="abs-width-600"> + <SentenceWithHighlights + highlightKeys={['default_msbuild']} + translationKey="onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.title" + /> + <Alert className="spacer-top" variant="info"> + {translate('onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.info')} + </Alert> + <ul className="list-styled"> + <li> + <SentenceWithHighlights + highlightKeys={['msbuild']} + translationKey="onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.step1" + /> + </li> + <li> + <SentenceWithHighlights + highlightKeys={['path']} + translationKey="onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.step2" + /> + </li> + <li> + <SentenceWithHighlights + highlightKeys={['msbuild', 'add_msbuild', 'name', 'msbuild_plugin']} + translationKey="onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.step3" + /> + <code className="rule">Default MSBuild</code> + <ClipboardIconButton copyValue="Default MSBuild" /> + </li> + </ul> + </li> + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNetPrereqsScanner.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNetPrereqsScanner.tsx new file mode 100644 index 00000000000..a68e7b1055b --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/DotNetPrereqsScanner.tsx @@ -0,0 +1,66 @@ +/* + * 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. + */ +import * as React from 'react'; +import { ClipboardIconButton } from 'sonar-ui-common/components/controls/clipboard'; +import { Alert } from 'sonar-ui-common/components/ui/Alert'; +import { translate } from 'sonar-ui-common/helpers/l10n'; +import SentenceWithHighlights from '../../components/SentenceWithHighlights'; + +export default function DotNetPrereqsScanner() { + return ( + <li className="abs-width-600"> + <SentenceWithHighlights + highlightKeys={['default_scanner']} + translationKey="onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.title" + /> + <Alert className="spacer-top" variant="info"> + {translate('onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.info')} + </Alert> + <ul className="list-styled"> + <li> + <SentenceWithHighlights + highlightKeys={['path']} + translationKey="onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step1" + /> + </li> + <li> + <SentenceWithHighlights + highlightKeys={['default_scanner', 'add_scanner_for_msbuild']} + translationKey="onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step2" + /> + </li> + <li> + <SentenceWithHighlights + highlightKeys={['name']} + translationKey="onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step3" + /> + <code className="rule">SonarScanner for MSBuild</code> + <ClipboardIconButton copyValue="SonarScanner for MSBuild" /> + </li> + <li> + <SentenceWithHighlights + highlightKeys={['install_from']} + translationKey="onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step5" + /> + </li> + </ul> + </li> + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetCore-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetCore-test.tsx new file mode 100644 index 00000000000..7656b8e39b4 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetCore-test.tsx @@ -0,0 +1,36 @@ +/* + * 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. + */ +import { shallow } from 'enzyme'; +import * as React from 'react'; +import { mockComponent } from '../../../../../helpers/testMocks'; +import { OSs } from '../../../types'; +import { DotNetCoreFrameworkProps } from '../DotNet'; +import DotNetCore from '../DotNetCore'; + +it('should render correctly', () => { + expect(shallowRender()).toMatchSnapshot('win'); + expect(shallowRender({ os: OSs.Linux })).toMatchSnapshot('linux'); +}); + +function shallowRender(props: Partial<DotNetCoreFrameworkProps> = {}) { + return shallow<DotNetCoreFrameworkProps>( + <DotNetCore component={mockComponent()} os={OSs.Windows} {...props} /> + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetFramework-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetFramework-test.tsx new file mode 100644 index 00000000000..44837fe60cf --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetFramework-test.tsx @@ -0,0 +1,35 @@ +/* + * 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. + */ +import { shallow } from 'enzyme'; +import * as React from 'react'; +import { mockComponent } from '../../../../../helpers/testMocks'; +import { OSs } from '../../../types'; +import { DotNetCoreFrameworkProps } from '../DotNet'; +import DotNetFramework from '../DotNetFramework'; + +it('should render correctly', () => { + expect(shallowRender()).toMatchSnapshot(); +}); + +function shallowRender(props: Partial<DotNetCoreFrameworkProps> = {}) { + return shallow<DotNetCoreFrameworkProps>( + <DotNetFramework component={mockComponent()} os={OSs.Windows} {...props} /> + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetPrereqsMSBuild-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetPrereqsMSBuild-test.tsx new file mode 100644 index 00000000000..b559ae08a8a --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetPrereqsMSBuild-test.tsx @@ -0,0 +1,30 @@ +/* + * 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. + */ +import { shallow } from 'enzyme'; +import * as React from 'react'; +import DotNetPrereqsMSBuild from '../DotNetPrereqsMSBuild'; + +it('should render correctly', () => { + expect(shallowRender()).toMatchSnapshot(); +}); + +function shallowRender() { + return shallow(<DotNetPrereqsMSBuild />); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetPrereqsScanner-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetPrereqsScanner-test.tsx new file mode 100644 index 00000000000..93c95b2ba81 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/DotNetPrereqsScanner-test.tsx @@ -0,0 +1,30 @@ +/* + * 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. + */ +import { shallow } from 'enzyme'; +import * as React from 'react'; +import DotNetPrereqsScanner from '../DotNetPrereqsScanner'; + +it('should render correctly', () => { + expect(shallowRender()).toMatchSnapshot(); +}); + +function shallowRender() { + return shallow(<DotNetPrereqsScanner />); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNet-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNet-test.tsx.snap index 60f35c80bab..60d9bf011b9 100644 --- a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNet-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNet-test.tsx.snap @@ -1,91 +1,21 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`should render correctly 1`] = ` -<li - className="abs-width-600" -> - <SentenceWithFilename - filename="Jenkinsfile" - translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.jenkinsfile_step" - /> - <Alert - className="spacer-top" - variant="info" - > - <p - className="text-middle" - > - <SentenceWithHighlights - highlightKeys={ - Array [ - "default_msbuild", - "default_scanner", - "in_jenkins", - ] - } - translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.replace" - /> - <HelpTooltip - className="little-spacer-left" - overlay={ - <React.Fragment> - <p - className="spacer-bottom" - > - <SentenceWithHighlights - highlightKeys={ - Array [ - "path", - ] - } - translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help1" - /> - </p> - <p - className="spacer-bottom" - > - <SentenceWithHighlights - highlightKeys={ - Array [ - "path", - "name", - ] - } - translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help2" - /> - </p> - <p> - <SentenceWithHighlights - highlightKeys={ - Array [ - "path", - "name", - ] - } - translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help3" - /> - </p> - </React.Fragment> - } - /> - </p> - </Alert> - <CodeSnippet - snippet="node { - stage('SCM') { - checkout scm - } - stage('SonarQube Analysis') { - def msbuildHome = tool 'Default MSBuild' - def scannerHome = tool 'SonarScanner for MSBuild' - withSonarQubeEnv() { - bat \\"\\\\\\"\${scannerHome}\\\\\\\\SonarScanner.MSBuild.exe\\\\\\" begin /k:\\\\\\"my-project\\\\\\"\\" - bat \\"\\\\\\"\${msbuildHome}\\\\\\\\MSBuild.exe\\\\\\" /t:Rebuild\\" - bat \\"\\\\\\"\${scannerHome}\\\\\\\\SonarScanner.MSBuild.exe\\\\\\" end\\" - } - } -} -" - /> -</li> +<Fragment> + <li> + onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.build_agent + <RenderOptions + name="flavorComponent" + onCheck={[Function]} + optionLabelKey="onboarding.build.dotnet" + options={ + Array [ + "win_core", + "win_msbuild", + "linux_core", + ] + } + /> + </li> +</Fragment> `; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetCore-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetCore-test.tsx.snap new file mode 100644 index 00000000000..d3e6b656151 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetCore-test.tsx.snap @@ -0,0 +1,61 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly: linux 1`] = ` +<Fragment> + <DotNetPrereqsScanner /> + <li + className="abs-width-600" + > + <SentenceWithFilename + filename="Jenkinsfile" + translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.jenkinsfile_step" + /> + <CodeSnippet + snippet="node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + sh \\"dotnet \${scannerHome}/SonarScanner.MSBuild.dll begin /k:\\\\\\"my-project\\\\\\"\\" + sh \\"dotnet build\\" + sh \\"dotnet \${scannerHome}/SonarScanner.MSBuild.dll end\\" + } + } +} +" + /> + </li> +</Fragment> +`; + +exports[`should render correctly: win 1`] = ` +<Fragment> + <DotNetPrereqsScanner /> + <li + className="abs-width-600" + > + <SentenceWithFilename + filename="Jenkinsfile" + translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.jenkinsfile_step" + /> + <CodeSnippet + snippet="node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + bat \\"dotnet \${scannerHome}\\\\\\\\SonarScanner.MSBuild.dll begin /k:\\\\\\"my-project\\\\\\"\\" + bat \\"dotnet build\\" + bat \\"dotnet \${scannerHome}\\\\\\\\SonarScanner.MSBuild.dll end\\" + } + } +} +" + /> + </li> +</Fragment> +`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetFramework-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetFramework-test.tsx.snap new file mode 100644 index 00000000000..c5d2c7107de --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetFramework-test.tsx.snap @@ -0,0 +1,33 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` +<Fragment> + <DotNetPrereqsScanner /> + <DotNetPrereqsMSBuild /> + <li + className="abs-width-600" + > + <SentenceWithFilename + filename="Jenkinsfile" + translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.jenkinsfile_step" + /> + <CodeSnippet + snippet="node { + stage('SCM') { + checkout scm + } + stage('SonarQube Analysis') { + def msbuildHome = tool 'Default MSBuild' + def scannerHome = tool 'SonarScanner for MSBuild' + withSonarQubeEnv() { + bat \\"\\\\\\"\${scannerHome}\\\\\\\\SonarScanner.MSBuild.exe\\\\\\" begin /k:\\\\\\"my-project\\\\\\"\\" + bat \\"\\\\\\"\${msbuildHome}\\\\\\\\MSBuild.exe\\\\\\" /t:Rebuild\\" + bat \\"\\\\\\"\${scannerHome}\\\\\\\\SonarScanner.MSBuild.exe\\\\\\" end\\" + } + } +} +" + /> + </li> +</Fragment> +`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetPrereqsMSBuild-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetPrereqsMSBuild-test.tsx.snap new file mode 100644 index 00000000000..5352256cc55 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetPrereqsMSBuild-test.tsx.snap @@ -0,0 +1,67 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` +<li + className="abs-width-600" +> + <SentenceWithHighlights + highlightKeys={ + Array [ + "default_msbuild", + ] + } + translationKey="onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.title" + /> + <Alert + className="spacer-top" + variant="info" + > + onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.info + </Alert> + <ul + className="list-styled" + > + <li> + <SentenceWithHighlights + highlightKeys={ + Array [ + "msbuild", + ] + } + translationKey="onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.step1" + /> + </li> + <li> + <SentenceWithHighlights + highlightKeys={ + Array [ + "path", + ] + } + translationKey="onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.step2" + /> + </li> + <li> + <SentenceWithHighlights + highlightKeys={ + Array [ + "msbuild", + "add_msbuild", + "name", + "msbuild_plugin", + ] + } + translationKey="onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.step3" + /> + <code + className="rule" + > + Default MSBuild + </code> + <ClipboardIconButton + copyValue="Default MSBuild" + /> + </li> + </ul> +</li> +`; diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetPrereqsScanner-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetPrereqsScanner-test.tsx.snap new file mode 100644 index 00000000000..86e44d5182a --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/buildtool-steps/__tests__/__snapshots__/DotNetPrereqsScanner-test.tsx.snap @@ -0,0 +1,75 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` +<li + className="abs-width-600" +> + <SentenceWithHighlights + highlightKeys={ + Array [ + "default_scanner", + ] + } + translationKey="onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.title" + /> + <Alert + className="spacer-top" + variant="info" + > + onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.info + </Alert> + <ul + className="list-styled" + > + <li> + <SentenceWithHighlights + highlightKeys={ + Array [ + "path", + ] + } + translationKey="onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step1" + /> + </li> + <li> + <SentenceWithHighlights + highlightKeys={ + Array [ + "default_scanner", + "add_scanner_for_msbuild", + ] + } + translationKey="onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step2" + /> + </li> + <li> + <SentenceWithHighlights + highlightKeys={ + Array [ + "name", + ] + } + translationKey="onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step3" + /> + <code + className="rule" + > + SonarScanner for MSBuild + </code> + <ClipboardIconButton + copyValue="SonarScanner for MSBuild" + /> + </li> + <li> + <SentenceWithHighlights + highlightKeys={ + Array [ + "install_from", + ] + } + translationKey="onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step5" + /> + </li> + </ul> +</li> +`; diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/Other-test.tsx b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/Other-test.tsx index 70e9c3ef615..751a95f8cd5 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/Other-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/Other-test.tsx @@ -23,9 +23,7 @@ import { OSs } from '../../../types'; import Other, { OtherProps } from '../Other'; it('renders correctly', () => { - expect(shallowRender()).toMatchSnapshot('linux'); - expect(shallowRender({ os: OSs.Windows })).toMatchSnapshot('windows'); - expect(shallowRender({ os: OSs.MacOS })).toMatchSnapshot('macos'); + expect(shallowRender()).toMatchSnapshot(); }); function shallowRender(props: Partial<OtherProps> = {}) { diff --git a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/Other-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/Other-test.tsx.snap index 15cc7f98669..f031c8c142c 100644 --- a/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/Other-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/manual/commands/__tests__/__snapshots__/Other-test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`renders correctly: linux 1`] = ` +exports[`renders correctly 1`] = ` <div> <SQScanner os="linux" @@ -13,31 +13,3 @@ exports[`renders correctly: linux 1`] = ` /> </div> `; - -exports[`renders correctly: macos 1`] = ` -<div> - <SQScanner - os="mac" - /> - <ExecScanner - host="host" - os="mac" - projectKey="projectKey" - token="token" - /> -</div> -`; - -exports[`renders correctly: windows 1`] = ` -<div> - <SQScanner - os="win" - /> - <ExecScanner - host="host" - os="win" - projectKey="projectKey" - token="token" - /> -</div> -`; 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 04d2de164c0..fd7b55aecb6 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -3304,6 +3304,9 @@ onboarding.build.maven=Maven onboarding.build.gradle=Gradle onboarding.build.make=Make onboarding.build.dotnet=.NET +onboarding.build.dotnet.win_core=Windows + .NET Core +onboarding.build.dotnet.win_msbuild=Windows + .NET Framework +onboarding.build.dotnet.linux_core=Linux + .NET Core onboarding.build.cfamily=C,C++ or ObjC onboarding.build.other=Other (for JS, TS, Go, Python, PHP, ...) @@ -3575,18 +3578,38 @@ onboarding.tutorial.with.jenkins.jenkinsfile.maven.step3.help2.sentence=The name onboarding.tutorial.with.jenkins.jenkinsfile.maven.step3.help2.sentence.path=Maven > Maven installations onboarding.tutorial.with.jenkins.jenkinsfile.maven.step3.help2.sentence.name=Name onboarding.tutorial.with.jenkins.jenkinsfile.gradle.step2.sentence=Add the following to your {file} file: -onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.replace.sentence=Make sure to replace {default_msbuild} and {default_scanner} with the names you gave to your MSBuild and SonarScanner for MSBuild tools {in_jenkins}. -onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.replace.sentence.default_msbuild=Default MSBuild -onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.replace.sentence.default_scanner=SonarScanner for MSBuild -onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.replace.sentence.in_jenkins=in Jenkins -onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help1.sentence=To get the name of these tools in Jenkins, navigate to {path}. -onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help1.sentence.path=Manage Jenkins > Global Tool Configuration -onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help2.sentence=For your MSBuild tool, the name is located under the {path} section, in the {name} field. -onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help2.sentence.path=MSBuild > MSBuild installations -onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help2.sentence.name=Name -onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help3.sentence=For your SonarScanner for MSBuild tool, the name is located under the {path} section, in the {name} field. -onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help3.sentence.path=SonarScanner for MSBuild > SonarScanner for MSBuild installations -onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.step2.help3.sentence.name=Name +onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.build_agent=Choose your build agent. + +onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.title.sentence=Prerequisite: Add a {default_msbuild} tool +onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.title.sentence.default_msbuild=MSBuild +onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.info=This step need to be done only once per jenkins instance. +onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.step1.sentence=In Jenkins, make sure to have the {msbuild} installed. +onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.step1.sentence.msbuild=MSBuild Plugin +onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.step2.sentence=Navigate to {path}. +onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.step2.sentence.path=Manage Jenkins > Global Tool Configuration +onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.step3.sentence=Under {msbuild} click on {add_msbuild} and give a {name} that will be used in the last step. Refer to the {msbuild_plugin} documentation on how to install the tool: +onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.step3.sentence.msbuild=MSBuild +onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.step3.sentence.msbuild_plugin=MSBuild Plugin +onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.step3.sentence.add_msbuild=Add MSBuild +onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.step3.sentence.name=Name + + +onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.title.sentence=Prerequisite: Add a {default_scanner} tool +onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.title.sentence.default_scanner=SonarScanner for MSBuild +onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.info=This step needs to be done only once per jenkins instance or if you need different scanner versions. +onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step1.sentence=In Jenkins, navigate to {path}. +onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step1.sentence.path=Manage Jenkins > Global Tool Configuration +onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step2.sentence=Under {default_scanner} click on {add_scanner_for_msbuild} +onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step2.sentence.default_scanner=SonarScanner for MSBuild +onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step2.sentence.add_scanner_for_msbuild=Add SonarScanner for MSBuild +onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step3.sentence=Choose a {name} that will be used in the last step: +onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step3.sentence.name=Name +onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step4.sentence=Check {install_auto} +onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step4.sentence.install_auto=Install automatically +onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step5.sentence=Under {install_from} select the corresponding .NET Core scanner required for you project. +onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step5.sentence.install_from=Install from GitHub +onboarding.tutorial.with.jenkins.dotnet.scanner.prereqs.step5.sentence.install_auto=Install automatically + onboarding.tutorial.with.jenkins.jenkinsfile.other.step2.sentence=Create a {file} file in your repository and paste the following code: onboarding.tutorial.with.jenkins.jenkinsfile.other.step3.replace.sentence=Make sure to replace {default} with the name you gave to your SonarQube Scanner tool {in_jenkins}. onboarding.tutorial.with.jenkins.jenkinsfile.other.step3.replace.sentence.default=SonarScanner |