]> source.dussan.org Git - sonarqube.git/blob
dc6e5975f2fb60ec62fa8521ab38898cd1f2ac8c
[sonarqube.git] /
1 /*
2  * SonarQube
3  * Copyright (C) 2009-2023 SonarSource SA
4  * mailto:info AT sonarsource DOT com
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 3 of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20 import * as React from 'react';
21 import { FormattedMessage } from 'react-intl';
22 import { ClipboardIconButton } from '../../../../components/controls/clipboard';
23 import { translate } from '../../../../helpers/l10n';
24 import CodeSnippet from '../../../common/CodeSnippet';
25 import SentenceWithHighlights from '../../components/SentenceWithHighlights';
26 import { BuildTools } from '../../types';
27
28 export enum PrepareType {
29   JavaMavenGradle,
30   StandAlone,
31   MSBuild,
32 }
33
34 export interface PrepareAnalysisCommandProps {
35   buildTool: BuildTools;
36   kind: PrepareType;
37   projectKey: string;
38   projectName?: string;
39 }
40
41 export default function PrepareAnalysisCommand(props: PrepareAnalysisCommandProps) {
42   const { buildTool, kind, projectKey, projectName } = props;
43
44   const ADDITIONAL_PROPERTY = 'sonar.cfamily.build-wrapper-output=bw-output';
45
46   const MAVEN_GRADLE_PROPS_SNIPPET = `# Additional properties that will be passed to the scanner,
47 # Put one key=value per line, example:
48 # sonar.exclusions=**/*.bin
49 sonar.projectKey=${projectKey}
50 sonar.projectName=${projectName}
51 `;
52
53   return (
54     <ul className="list-styled list-alpha spacer-top">
55       <li>
56         <SentenceWithHighlights
57           translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.endpoint"
58           highlightKeys={['endpoint']}
59         />
60       </li>
61       <li>
62         <FormattedMessage
63           id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis"
64           defaultMessage={translate(
65             'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis'
66           )}
67           values={{
68             section: (
69               <strong>
70                 {translate(
71                   'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis.section'
72                 )}
73               </strong>
74             ),
75             run_analysis_value: (
76               <strong>
77                 {translate(
78                   'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis.values',
79                   buildTool
80                 )}
81               </strong>
82             ),
83           }}
84         />
85       </li>
86
87       {kind === PrepareType.StandAlone && (
88         <>
89           <li>
90             <SentenceWithHighlights
91               translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.manual"
92               highlightKeys={['mode']}
93             />
94           </li>
95
96           <li>
97             <FormattedMessage
98               id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence"
99               defaultMessage={translate(
100                 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence'
101               )}
102               values={{
103                 project_key: (
104                   <b>
105                     {translate(
106                       'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence.project_key'
107                     )}
108                   </b>
109                 ),
110                 key: <code className="rule">{projectKey}</code>,
111                 button: <ClipboardIconButton copyValue={projectKey} />,
112               }}
113             />
114           </li>
115           {buildTool === BuildTools.CFamily && (
116             <li>
117               <FormattedMessage
118                 id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp"
119                 defaultMessage={translate(
120                   'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp'
121                 )}
122                 values={{
123                   advanced: (
124                     <b>
125                       {translate(
126                         'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp.advanced'
127                       )}
128                     </b>
129                   ),
130                   additional: (
131                     <b>
132                       {translate(
133                         'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp.additional'
134                       )}
135                     </b>
136                   ),
137                   property: <code className="rule">{ADDITIONAL_PROPERTY}</code>,
138                   button: <ClipboardIconButton copyValue={ADDITIONAL_PROPERTY} />,
139                 }}
140               />
141             </li>
142           )}
143         </>
144       )}
145
146       {kind === PrepareType.JavaMavenGradle && (
147         <li>
148           <SentenceWithHighlights
149             translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.advanced_properties"
150             highlightKeys={['section', 'properties']}
151           />
152           :
153           <CodeSnippet snippet={MAVEN_GRADLE_PROPS_SNIPPET} />
154         </li>
155       )}
156       {kind === PrepareType.MSBuild && (
157         <li>
158           <FormattedMessage
159             id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence"
160             defaultMessage={translate(
161               'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence'
162             )}
163             values={{
164               project_key: (
165                 <b>
166                   {translate(
167                     'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence.project_key'
168                   )}
169                 </b>
170               ),
171               key: <code className="rule">{projectKey}</code>,
172               button: <ClipboardIconButton copyValue={projectKey} />,
173             }}
174           />
175         </li>
176       )}
177     </ul>
178   );
179 }