]> source.dussan.org Git - sonarqube.git/blob
cc7f878b1d12797e60b44646d84d71364106f0c5
[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 }
39
40 export default function PrepareAnalysisCommand(props: PrepareAnalysisCommandProps) {
41   const { buildTool, kind, projectKey } = props;
42
43   const ADDITIONAL_PROPERTY = 'sonar.cfamily.build-wrapper-output=bw-output';
44
45   const MAVEN_GRADLE_PROPS_SNIPPET = `# Additional properties that will be passed to the scanner,
46 # Put one key=value per line, example:
47 # sonar.exclusions=**/*.bin
48 sonar.projectKey=${projectKey}`;
49
50   return (
51     <ul className="list-styled list-alpha spacer-top">
52       <li>
53         <SentenceWithHighlights
54           translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.endpoint"
55           highlightKeys={['endpoint']}
56         />
57       </li>
58       <li>
59         <FormattedMessage
60           id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis"
61           defaultMessage={translate(
62             'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis'
63           )}
64           values={{
65             section: (
66               <strong>
67                 {translate(
68                   'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis.section'
69                 )}
70               </strong>
71             ),
72             run_analysis_value: (
73               <strong>
74                 {translate(
75                   'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis.values',
76                   buildTool
77                 )}
78               </strong>
79             ),
80           }}
81         />
82       </li>
83
84       {kind === PrepareType.StandAlone && (
85         <>
86           <li>
87             <SentenceWithHighlights
88               translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.manual"
89               highlightKeys={['mode']}
90             />
91           </li>
92
93           <li>
94             <FormattedMessage
95               id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence"
96               defaultMessage={translate(
97                 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence'
98               )}
99               values={{
100                 project_key: (
101                   <b>
102                     {translate(
103                       'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence.project_key'
104                     )}
105                   </b>
106                 ),
107                 key: <code className="rule">{projectKey}</code>,
108                 button: <ClipboardIconButton copyValue={projectKey} />,
109               }}
110             />
111           </li>
112           {buildTool === BuildTools.CFamily && (
113             <li>
114               <FormattedMessage
115                 id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp"
116                 defaultMessage={translate(
117                   'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp'
118                 )}
119                 values={{
120                   advanced: (
121                     <b>
122                       {translate(
123                         'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp.advanced'
124                       )}
125                     </b>
126                   ),
127                   additional: (
128                     <b>
129                       {translate(
130                         'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp.additional'
131                       )}
132                     </b>
133                   ),
134                   property: <code className="rule">{ADDITIONAL_PROPERTY}</code>,
135                   button: <ClipboardIconButton copyValue={ADDITIONAL_PROPERTY} />,
136                 }}
137               />
138             </li>
139           )}
140         </>
141       )}
142
143       {kind === PrepareType.JavaMavenGradle && (
144         <li>
145           <SentenceWithHighlights
146             translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.advanced_properties"
147             highlightKeys={['section', 'properties']}
148           />
149           :
150           <CodeSnippet snippet={MAVEN_GRADLE_PROPS_SNIPPET} />
151         </li>
152       )}
153       {kind === PrepareType.MSBuild && (
154         <li>
155           <FormattedMessage
156             id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence"
157             defaultMessage={translate(
158               'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence'
159             )}
160             values={{
161               project_key: (
162                 <b>
163                   {translate(
164                     'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence.project_key'
165                   )}
166                 </b>
167               ),
168               key: <code className="rule">{projectKey}</code>,
169               button: <ClipboardIconButton copyValue={projectKey} />,
170             }}
171           />
172         </li>
173       )}
174     </ul>
175   );
176 }