diff options
author | Wouter Admiraal <wouter.admiraal@sonarsource.com> | 2022-10-27 15:42:08 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-10-28 20:03:23 +0000 |
commit | a57bb80ea7d4c90e12c2410cb384d9152225c055 (patch) | |
tree | 9b396c0498e713101c2db966b9c32284d7a4ca3f /server/sonar-web/src/main/js | |
parent | f96072d85c7c351c40c5e2528f03a4f31abeea73 (diff) | |
download | sonarqube-a57bb80ea7d4c90e12c2410cb384d9152225c055.tar.gz sonarqube-a57bb80ea7d4c90e12c2410cb384d9152225c055.zip |
SONAR-17528 Update tutorials to use the actual main branch name
Diffstat (limited to 'server/sonar-web/src/main/js')
64 files changed, 606 insertions, 1362 deletions
diff --git a/server/sonar-web/src/main/js/api/mocks/SettingsServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/SettingsServiceMock.ts index 4ac206dbf5d..7d22006a564 100644 --- a/server/sonar-web/src/main/js/api/mocks/SettingsServiceMock.ts +++ b/server/sonar-web/src/main/js/api/mocks/SettingsServiceMock.ts @@ -21,7 +21,7 @@ import { cloneDeep } from 'lodash'; import { HousekeepingPolicy } from '../../apps/audit-logs/utils'; import { BranchParameters } from '../../types/branch-like'; import { SettingsKey, SettingValue } from '../../types/settings'; -import { getValue } from '../settings'; +import { getAllValues, getValue, getValues } from '../settings'; export default class SettingsServiceMock { settingValues: SettingValue[]; @@ -34,28 +34,43 @@ export default class SettingsServiceMock { constructor() { this.settingValues = cloneDeep(this.defaultValues); - (getValue as jest.Mock).mockImplementation(this.handleGetValues); + (getValue as jest.Mock).mockImplementation(this.handleGetValue); + (getValues as jest.Mock).mockImplementation(this.handleGetValues); + (getAllValues as jest.Mock).mockImplementation(this.handleGetAllValues); } - handleGetValues = (data: { key: string; component?: string } & BranchParameters) => { + handleGetValue = (data: { key: string; component?: string } & BranchParameters) => { const setting = this.settingValues.find(s => s.key === data.key); - return this.reply(setting); }; - emptySettings() { + handleGetValues = (data: { keys: string[]; component?: string } & BranchParameters) => { + const settings = this.settingValues.filter(s => data.keys.includes(s.key)); + return this.reply(settings); + }; + + handleGetAllValues = () => { + return this.reply(this.settingValues); + }; + + emptySettings = () => { this.settingValues = []; - } + return this; + }; - setYearlyHousekeepingPolicy() { - const auditSetting = this.settingValues.find(s => s.key === SettingsKey.AuditHouseKeeping); - if (auditSetting) { - auditSetting.value = HousekeepingPolicy.Yearly; + set = (key: SettingsKey, value: string) => { + const setting = this.settingValues.find(s => s.key === key); + if (setting) { + setting.value = value; + } else { + this.settingValues.push({ key, value }); } - } + return this; + }; - resetSettingvalues = () => { + reset = () => { this.settingValues = cloneDeep(this.defaultValues); + return this; }; reply<T>(response: T): Promise<T> { diff --git a/server/sonar-web/src/main/js/apps/audit-logs/components/__tests__/AuditApp-it.tsx b/server/sonar-web/src/main/js/apps/audit-logs/components/__tests__/AuditApp-it.tsx index 813ede23e2d..1130413e4d6 100644 --- a/server/sonar-web/src/main/js/apps/audit-logs/components/__tests__/AuditApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/audit-logs/components/__tests__/AuditApp-it.tsx @@ -27,7 +27,9 @@ import { now } from '../../../../helpers/dates'; import { getShortMonthName } from '../../../../helpers/l10n'; import { renderAppWithAdminContext } from '../../../../helpers/testReactTestingUtils'; import { AdminPageExtension } from '../../../../types/extension'; +import { SettingsKey } from '../../../../types/settings'; import routes from '../../routes'; +import { HousekeepingPolicy } from '../../utils'; jest.mock('../../../../api/settings'); @@ -73,11 +75,11 @@ beforeAll(() => { handler = new SettingsServiceMock(); }); -afterEach(() => handler.resetSettingvalues()); +afterEach(() => handler.reset()); it('should handle download button click', async () => { const user = userEvent.setup(); - handler.setYearlyHousekeepingPolicy(); + handler.set(SettingsKey.AuditHouseKeeping, HousekeepingPolicy.Yearly); renderAuditLogs(); const downloadButton = await ui.downloadButton.find(); expect(downloadButton).toBeInTheDocument(); @@ -152,7 +154,7 @@ it('should show right option when keeping log for month', async () => { }); it('should show right option when keeping log for year', async () => { - handler.setYearlyHousekeepingPolicy(); + handler.set(SettingsKey.AuditHouseKeeping, HousekeepingPolicy.Yearly); renderAuditLogs(); expect(await ui.pageTitle.find()).toBeInTheDocument(); expect(ui.todayRadio.get()).toBeInTheDocument(); diff --git a/server/sonar-web/src/main/js/components/tutorials/TutorialSelection.tsx b/server/sonar-web/src/main/js/components/tutorials/TutorialSelection.tsx index 9888924b8e9..661ef43a318 100644 --- a/server/sonar-web/src/main/js/components/tutorials/TutorialSelection.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/TutorialSelection.tsx @@ -21,9 +21,12 @@ import * as React from 'react'; import { getAlmSettingsNoCatch } from '../../api/alm-settings'; import { getScannableProjects } from '../../api/components'; import { getValue } from '../../api/settings'; +import { ComponentContext } from '../../app/components/componentContext/ComponentContext'; +import { isMainBranch } from '../../helpers/branch-like'; import { getHostUrl } from '../../helpers/urls'; import { hasGlobalPermission } from '../../helpers/users'; import { AlmSettingsInstance, ProjectAlmBindingResponse } from '../../types/alm-settings'; +import { MainBranch } from '../../types/branch-like'; import { Permissions } from '../../types/permissions'; import { SettingsKey } from '../../types/settings'; import { Component } from '../../types/types'; @@ -48,6 +51,8 @@ interface State { loading: boolean; } +const DEFAULT_MAIN_BRANCH_NAME = 'main'; + export class TutorialSelection extends React.PureComponent<Props, State> { mounted = false; state: State = { @@ -134,18 +139,26 @@ export class TutorialSelection extends React.PureComponent<Props, State> { const selectedTutorial: TutorialModes | undefined = location.query?.selectedTutorial; return ( - <TutorialSelectionRenderer - almBinding={almBinding} - baseUrl={baseUrl} - component={component} - currentUser={currentUser} - currentUserCanScanProject={currentUserCanScanProject} - loading={loading} - onSelectTutorial={this.handleSelectTutorial} - projectBinding={projectBinding} - selectedTutorial={selectedTutorial} - willRefreshAutomatically={willRefreshAutomatically} - /> + <ComponentContext.Consumer> + {({ branchLikes }) => ( + <TutorialSelectionRenderer + almBinding={almBinding} + baseUrl={baseUrl} + component={component} + currentUser={currentUser} + currentUserCanScanProject={currentUserCanScanProject} + loading={loading} + mainBranchName={ + (branchLikes.find(b => isMainBranch(b)) as MainBranch | undefined)?.name || + DEFAULT_MAIN_BRANCH_NAME + } + onSelectTutorial={this.handleSelectTutorial} + projectBinding={projectBinding} + selectedTutorial={selectedTutorial} + willRefreshAutomatically={willRefreshAutomatically} + /> + )} + </ComponentContext.Consumer> ); } } 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 f08f088b801..fdaaeacad27 100644 --- a/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx @@ -40,6 +40,7 @@ export interface TutorialSelectionRendererProps { currentUser: LoggedInUser; currentUserCanScanProject: boolean; loading: boolean; + mainBranchName: string; onSelectTutorial: (mode: TutorialModes) => void; projectBinding?: ProjectAlmBindingResponse; selectedTutorial?: TutorialModes; @@ -77,13 +78,14 @@ export default function TutorialSelectionRenderer(props: TutorialSelectionRender currentUser, currentUserCanScanProject, loading, + mainBranchName, projectBinding, selectedTutorial, willRefreshAutomatically } = props; if (loading) { - return <i className="spinner" />; + return <i aria-label={translate('loading')} className="spinner" />; } if (!currentUserCanScanProject) { @@ -99,7 +101,7 @@ export default function TutorialSelectionRenderer(props: TutorialSelectionRender if (projectBinding !== undefined) { showGitHubActions = projectBinding.alm === AlmKeys.GitHub; showGitLabCICD = projectBinding.alm === AlmKeys.GitLab; - showBitbucketPipelines = projectBinding?.alm === AlmKeys.BitbucketCloud; + showBitbucketPipelines = projectBinding.alm === AlmKeys.BitbucketCloud; showAzurePipelines = [AlmKeys.Azure, AlmKeys.GitHub].includes(projectBinding.alm); showJenkins = [ AlmKeys.BitbucketCloud, @@ -233,6 +235,7 @@ export default function TutorialSelectionRenderer(props: TutorialSelectionRender baseUrl={baseUrl} component={component} currentUser={currentUser} + mainBranchName={mainBranchName} projectBinding={projectBinding} willRefreshAutomatically={willRefreshAutomatically} /> @@ -253,13 +256,14 @@ export default function TutorialSelectionRenderer(props: TutorialSelectionRender baseUrl={baseUrl} component={component} currentUser={currentUser} + mainBranchName={mainBranchName} willRefreshAutomatically={willRefreshAutomatically} /> )} {selectedTutorial === TutorialModes.AzurePipelines && ( <AzurePipelinesTutorial - alm={almBinding?.alm} + alm={projectBinding?.alm} baseUrl={baseUrl} component={component} currentUser={currentUser} diff --git a/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelection-it.tsx b/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelection-it.tsx new file mode 100644 index 00000000000..b2c685971f1 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelection-it.tsx @@ -0,0 +1,206 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 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 { screen, waitFor } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import { UserEvent } from '@testing-library/user-event/dist/types/setup'; +import * as React from 'react'; +import { byLabelText, byRole, byText } from 'testing-library-selector'; +import { getAlmSettingsNoCatch } from '../../../api/alm-settings'; +import { getScannableProjects } from '../../../api/components'; +import SettingsServiceMock from '../../../api/mocks/SettingsServiceMock'; +import UserTokensMock from '../../../api/mocks/UserTokensMock'; +import { + mockGithubBindingDefinition, + mockProjectAlmBindingResponse +} from '../../../helpers/mocks/alm-settings'; +import { mockComponent } from '../../../helpers/mocks/component'; +import { mockLoggedInUser } from '../../../helpers/testMocks'; +import { renderApp } from '../../../helpers/testReactTestingUtils'; +import { AlmKeys } from '../../../types/alm-settings'; +import { Feature } from '../../../types/features'; +import { Permissions } from '../../../types/permissions'; +import { SettingsKey } from '../../../types/settings'; +import { withRouter } from '../../hoc/withRouter'; +import { TutorialSelection } from '../TutorialSelection'; +import { TutorialModes } from '../types'; + +jest.mock('../../../api/settings'); +jest.mock('../../../api/user-tokens'); + +jest.mock('../../../helpers/urls', () => ({ + ...jest.requireActual('../../../helpers/urls'), + getHostUrl: jest.fn().mockReturnValue('http://host.url') +})); + +jest.mock('../../../api/alm-settings', () => ({ + getAlmSettingsNoCatch: jest.fn().mockRejectedValue(null) +})); + +jest.mock('../../../api/components', () => ({ + getScannableProjects: jest.fn().mockResolvedValue({ projects: [] }) +})); + +let settingsMock: SettingsServiceMock; +let tokenMock: UserTokensMock; + +beforeAll(() => { + settingsMock = new SettingsServiceMock(); + tokenMock = new UserTokensMock(); +}); + +afterEach(() => { + tokenMock.reset(); + settingsMock.reset(); +}); + +beforeEach(jest.clearAllMocks); + +const ui = { + loading: byLabelText('loading'), + noScanRights: byText('onboarding.tutorial.no_scan_rights'), + chooseTutorialBtn: (mode: TutorialModes) => + byRole('button', { name: `onboarding.tutorial.choose_method.${mode}` }) +}; + +it.each([ + [TutorialModes.Jenkins, 'onboarding.tutorial.with.jenkins.title'], + [TutorialModes.AzurePipelines, 'onboarding.tutorial.with.azure_pipelines.title'], + [ + TutorialModes.BitbucketPipelines, + 'onboarding.tutorial.with.bitbucket_pipelines.create_secret.title' + ], + [TutorialModes.GitHubActions, 'onboarding.tutorial.with.github_action.create_secret.title'], + [TutorialModes.GitLabCI, 'onboarding.tutorial.with.gitlab_ci.title'], + [TutorialModes.Local, 'onboarding.project_analysis.header'], + [TutorialModes.OtherCI, 'onboarding.project_analysis.header'] +])('should behave correctly for %s', async (mode, title) => { + const user = userEvent.setup(); + renderTutorialSelection(); + await waitOnDataLoaded(); + + expect(screen.getByText('onboarding.tutorial.choose_method')).toBeInTheDocument(); + + await user.click(ui.chooseTutorialBtn(mode).get()); + expect(screen.getByText(title)).toBeInTheDocument(); +}); + +it.each([ + [ + AlmKeys.GitHub, + [TutorialModes.GitHubActions, TutorialModes.Jenkins, TutorialModes.AzurePipelines] + ], + [AlmKeys.GitLab, [TutorialModes.GitLabCI, TutorialModes.Jenkins]], + [AlmKeys.Azure, [TutorialModes.AzurePipelines]], + [AlmKeys.BitbucketServer, [TutorialModes.Jenkins]], + [AlmKeys.BitbucketCloud, [TutorialModes.BitbucketPipelines, TutorialModes.Jenkins]] +])('should show correct buttons if project is bound to %s', async (alm, modes) => { + renderTutorialSelection({ projectBinding: mockProjectAlmBindingResponse({ alm }) }); + await waitOnDataLoaded(); + + modes.forEach(mode => expect(ui.chooseTutorialBtn(mode).get()).toBeInTheDocument()); +}); + +it('should correctly fetch the corresponding ALM setting', async () => { + (getAlmSettingsNoCatch as jest.Mock).mockResolvedValueOnce([ + mockGithubBindingDefinition({ key: 'binding', url: 'https://enterprise.github.com' }) + ]); + const user = userEvent.setup(); + renderTutorialSelection({ + projectBinding: mockProjectAlmBindingResponse({ alm: AlmKeys.GitHub, key: 'binding' }) + }); + await waitOnDataLoaded(); + + await startJenkinsTutorial(user); + expect(screen.getByText('https://enterprise.github.com', { exact: false })).toBeInTheDocument(); +}); + +it('should correctly fetch the instance URL', async () => { + settingsMock.set(SettingsKey.ServerBaseUrl, 'http://sq.example.com'); + const user = userEvent.setup(); + renderTutorialSelection(); + await waitOnDataLoaded(); + + await startLocalTutorial(user); + expect( + screen.getByText('-Dsonar.host.url=http://sq.example.com', { exact: false }) + ).toBeInTheDocument(); +}); + +it('should fallback on the host URL', async () => { + const user = userEvent.setup(); + renderTutorialSelection(); + await waitOnDataLoaded(); + + await startLocalTutorial(user); + expect( + screen.getByText('-Dsonar.host.url=http://host.url', { exact: false }) + ).toBeInTheDocument(); +}); + +it('should not display a warning if the user has no global scan permission, but can scan the project', async () => { + (getScannableProjects as jest.Mock).mockResolvedValueOnce({ projects: [{ key: 'foo' }] }); + renderTutorialSelection({ currentUser: mockLoggedInUser() }); + await waitOnDataLoaded(); + + expect(ui.noScanRights.query()).not.toBeInTheDocument(); +}); + +it('should correctly display a warning if the user has no scan permissions', async () => { + renderTutorialSelection({ currentUser: mockLoggedInUser() }); + await waitOnDataLoaded(); + + expect(ui.noScanRights.query()).toBeInTheDocument(); +}); + +async function waitOnDataLoaded() { + await waitFor(() => { + expect(ui.loading.query()).not.toBeInTheDocument(); + }); +} + +async function startLocalTutorial(user: UserEvent) { + await user.click(ui.chooseTutorialBtn(TutorialModes.Local).get()); + await user.click(screen.getByRole('button', { name: 'onboarding.token.generate' })); + await user.click(screen.getByRole('button', { name: 'continue' })); + await user.click(screen.getByRole('button', { name: 'onboarding.build.maven' })); +} + +async function startJenkinsTutorial(user: UserEvent) { + await user.click(ui.chooseTutorialBtn(TutorialModes.Jenkins).get()); + await user.click( + screen.getByRole('button', { name: 'onboarding.tutorial.with.jenkins.prereqs.done' }) + ); +} + +function renderTutorialSelection(props: Partial<TutorialSelection['props']> = {}) { + const Wrapper = withRouter(({ router, location, ...subProps }: TutorialSelection['props']) => { + return <TutorialSelection location={location} router={router} {...subProps} />; + }); + + return renderApp( + '/', + <Wrapper + component={mockComponent({ key: 'foo' })} + currentUser={mockLoggedInUser({ permissions: { global: [Permissions.Scan] } })} + {...props} + />, + { featureList: [Feature.BranchSupport] } + ); +} diff --git a/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelection-test.tsx b/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelection-test.tsx deleted file mode 100644 index 80b92e0166b..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelection-test.tsx +++ /dev/null @@ -1,161 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2022 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 { getAlmSettingsNoCatch } from '../../../api/alm-settings'; -import { getScannableProjects } from '../../../api/components'; -import { getValue } from '../../../api/settings'; -import { - mockAlmSettingsInstance, - mockProjectBitbucketBindingResponse -} from '../../../helpers/mocks/alm-settings'; -import { mockComponent } from '../../../helpers/mocks/component'; -import { mockLocation, mockLoggedInUser, mockRouter } from '../../../helpers/testMocks'; -import { waitAndUpdate } from '../../../helpers/testUtils'; -import { getHostUrl } from '../../../helpers/urls'; -import { Permissions } from '../../../types/permissions'; -import { SettingsKey } from '../../../types/settings'; -import { TutorialSelection } from '../TutorialSelection'; -import { TutorialModes } from '../types'; - -jest.mock('../../../helpers/urls', () => ({ - getHostUrl: jest.fn().mockReturnValue('http://host.url') -})); - -jest.mock('../../../api/alm-settings', () => ({ - getAlmSettingsNoCatch: jest.fn().mockRejectedValue(null) -})); - -jest.mock('../../../api/settings', () => ({ - getValue: jest.fn().mockResolvedValue({}) -})); - -jest.mock('../../../api/components', () => ({ - getScannableProjects: jest.fn().mockResolvedValue({ projects: [] }) -})); - -beforeEach(jest.clearAllMocks); - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it('should correctly find the global ALM binding definition', async () => { - const key = 'foo'; - const almBinding = mockAlmSettingsInstance({ key }); - (getAlmSettingsNoCatch as jest.Mock).mockResolvedValueOnce([ - almBinding, - mockAlmSettingsInstance({ key: 'bar' }) - ]); - const wrapper = shallowRender({ projectBinding: mockProjectBitbucketBindingResponse({ key }) }); - await waitAndUpdate(wrapper); - expect(wrapper.state().almBinding).toBe(almBinding); -}); - -it('should handle selection', () => { - const push = jest.fn(); - const wrapper = shallowRender({ router: mockRouter({ push }) }); - const instance = wrapper.instance(); - - instance.handleSelectTutorial(TutorialModes.Local); - expect(push).toHaveBeenLastCalledWith( - expect.objectContaining({ - query: { selectedTutorial: TutorialModes.Local } - }) - ); - - instance.handleSelectTutorial(TutorialModes.Jenkins); - expect(push).toHaveBeenLastCalledWith( - expect.objectContaining({ - query: { selectedTutorial: TutorialModes.Jenkins } - }) - ); -}); - -it('should fetch the correct baseUrl', async () => { - (getValue as jest.Mock) - .mockResolvedValueOnce({ key: SettingsKey.ServerBaseUrl, value: '' }) - .mockResolvedValueOnce({ key: SettingsKey.ServerBaseUrl, value: 'http://sq.example.com' }) - .mockRejectedValueOnce(null); - - let wrapper = shallowRender(); - - expect(getValue).toHaveBeenCalled(); - expect(getHostUrl).toHaveBeenCalled(); - - // No baseURL, fallback to the URL in the browser. - await waitAndUpdate(wrapper); - expect(wrapper.state().baseUrl).toBe('http://host.url'); - - // A baseURL was set. - wrapper = shallowRender(); - await waitAndUpdate(wrapper); - expect(wrapper.state().baseUrl).toBe('http://sq.example.com'); - - // Access denied, fallback to the URL in the browser. - wrapper = shallowRender(); - await waitAndUpdate(wrapper); - expect(wrapper.state().baseUrl).toBe('http://host.url'); -}); - -it("should correctly determine the user's permission", async () => { - const component = mockComponent({ key: 'bar', name: 'Bar' }); - (getScannableProjects as jest.Mock) - .mockResolvedValueOnce({ - projects: [ - { key: 'foo', name: 'Foo' }, - { key: component.key, name: component.name } - ] - }) - .mockResolvedValueOnce({ projects: [{ key: 'foo', name: 'Foo' }] }); - - // Global scan permission. - let wrapper = shallowRender({ - component, - currentUser: mockLoggedInUser({ permissions: { global: [Permissions.Scan] } }) - }); - await waitAndUpdate(wrapper); - expect(wrapper.state().currentUserCanScanProject).toBe(true); - expect(getScannableProjects).not.toHaveBeenCalled(); - - // Project scan permission. - wrapper = shallowRender({ component }); - await waitAndUpdate(wrapper); - expect(getScannableProjects).toHaveBeenCalled(); - expect(wrapper.state().currentUserCanScanProject).toBe(true); - - // No scan permission. - wrapper = shallowRender({ component }); - await waitAndUpdate(wrapper); - expect(getScannableProjects).toHaveBeenCalledTimes(2); - expect(wrapper.state().currentUserCanScanProject).toBe(false); -}); - -function shallowRender(props: Partial<TutorialSelection['props']> = {}) { - return shallow<TutorialSelection>( - <TutorialSelection - component={mockComponent()} - currentUser={mockLoggedInUser()} - location={mockLocation()} - router={mockRouter()} - {...props} - /> - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelectionRenderer-test.tsx b/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelectionRenderer-test.tsx deleted file mode 100644 index b9200fbe082..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/__tests__/TutorialSelectionRenderer-test.tsx +++ /dev/null @@ -1,177 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2022 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 { - mockAlmSettingsInstance, - mockProjectAzureBindingResponse, - mockProjectBitbucketBindingResponse, - mockProjectBitbucketCloudBindingResponse, - mockProjectGithubBindingResponse, - mockProjectGitLabBindingResponse -} from '../../../helpers/mocks/alm-settings'; -import { mockComponent } from '../../../helpers/mocks/component'; -import { mockLoggedInUser } from '../../../helpers/testMocks'; -import { click } from '../../../helpers/testUtils'; -import TutorialSelectionRenderer, { - TutorialSelectionRendererProps -} from '../TutorialSelectionRenderer'; -import { TutorialModes } from '../types'; - -it.each([ - ['bitbucket server', mockProjectBitbucketBindingResponse()], - ['github', mockProjectGithubBindingResponse()], - ['gitlab', mockProjectGitLabBindingResponse()], - ['azure', mockProjectAzureBindingResponse()] -])('should render correctly for %s', (_, projectBinding) => { - expect(shallowRender({ projectBinding })).toMatchSnapshot(); -}); - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('selection'); - expect(shallowRender({ loading: true })).toMatchSnapshot('loading'); - expect(shallowRender({ selectedTutorial: TutorialModes.Local })).toMatchSnapshot( - 'manual tutorial' - ); - expect( - shallowRender({ - selectedTutorial: TutorialModes.Jenkins, - projectBinding: mockProjectBitbucketBindingResponse() - }) - ).toMatchSnapshot('jenkins tutorial'); - expect( - shallowRender({ - selectedTutorial: TutorialModes.GitHubActions, - projectBinding: mockProjectGithubBindingResponse() - }) - ).toMatchSnapshot('github actions tutorial'); - expect( - shallowRender({ - selectedTutorial: TutorialModes.GitLabCI, - projectBinding: mockProjectGitLabBindingResponse() - }) - ).toMatchSnapshot('gitlab tutorial'); - expect( - shallowRender({ - selectedTutorial: TutorialModes.AzurePipelines, - projectBinding: mockProjectAzureBindingResponse() - }) - ).toMatchSnapshot('azure pipelines tutorial'); - expect(shallowRender({ currentUserCanScanProject: false })).toMatchSnapshot( - 'user has no scan permission' - ); -}); - -it('should allow mode selection for Bitbucket', () => { - const onSelectTutorial = jest.fn(); - const wrapper = shallowRender({ - onSelectTutorial, - projectBinding: mockProjectBitbucketBindingResponse() - }); - - click(wrapper.find('button.tutorial-mode-jenkins')); - expect(onSelectTutorial).toHaveBeenLastCalledWith(TutorialModes.Jenkins); - - click(wrapper.find('button.tutorial-mode-local')); - expect(onSelectTutorial).toHaveBeenLastCalledWith(TutorialModes.Local); -}); - -it('should allow mode selection for Github', () => { - const onSelectTutorial = jest.fn(); - const wrapper = shallowRender({ - onSelectTutorial, - projectBinding: mockProjectGithubBindingResponse() - }); - - click(wrapper.find('button.tutorial-mode-jenkins')); - expect(onSelectTutorial).toHaveBeenLastCalledWith(TutorialModes.Jenkins); - - click(wrapper.find('button.tutorial-mode-local')); - expect(onSelectTutorial).toHaveBeenLastCalledWith(TutorialModes.Local); - - click(wrapper.find('button.tutorial-mode-github-actions')); - expect(onSelectTutorial).toHaveBeenLastCalledWith(TutorialModes.GitHubActions); - - click(wrapper.find('button.tutorial-mode-azure-pipelines')); - expect(onSelectTutorial).toHaveBeenLastCalledWith(TutorialModes.AzurePipelines); -}); - -it('should allow mode selection for GitLab', () => { - const onSelectTutorial = jest.fn(); - const wrapper = shallowRender({ - onSelectTutorial, - projectBinding: mockProjectGitLabBindingResponse() - }); - - click(wrapper.find('button.tutorial-mode-jenkins')); - expect(onSelectTutorial).toHaveBeenLastCalledWith(TutorialModes.Jenkins); - - click(wrapper.find('button.tutorial-mode-gitlab-ci')); - expect(onSelectTutorial).toHaveBeenLastCalledWith(TutorialModes.GitLabCI); - - click(wrapper.find('button.tutorial-mode-local')); - expect(onSelectTutorial).toHaveBeenLastCalledWith(TutorialModes.Local); -}); - -it('should allow mode selection for Bitbucket pipepline', () => { - const onSelectTutorial = jest.fn(); - const wrapper = shallowRender({ - onSelectTutorial, - projectBinding: mockProjectBitbucketCloudBindingResponse() - }); - - click(wrapper.find('button.tutorial-mode-jenkins')); - expect(onSelectTutorial).toHaveBeenLastCalledWith(TutorialModes.Jenkins); - - click(wrapper.find('button.tutorial-mode-bitbucket-pipelines')); - expect(onSelectTutorial).toHaveBeenLastCalledWith(TutorialModes.BitbucketPipelines); - - click(wrapper.find('button.tutorial-mode-local')); - expect(onSelectTutorial).toHaveBeenLastCalledWith(TutorialModes.Local); -}); - -it('should allow mode selection for Azure DevOps', () => { - const onSelectTutorial = jest.fn(); - const wrapper = shallowRender({ - onSelectTutorial, - projectBinding: mockProjectAzureBindingResponse() - }); - - click(wrapper.find('button.tutorial-mode-azure-pipelines')); - expect(onSelectTutorial).toHaveBeenLastCalledWith(TutorialModes.AzurePipelines); - - click(wrapper.find('button.tutorial-mode-local')); - expect(onSelectTutorial).toHaveBeenLastCalledWith(TutorialModes.Local); -}); - -function shallowRender(props: Partial<TutorialSelectionRendererProps> = {}) { - return shallow<TutorialSelectionRendererProps>( - <TutorialSelectionRenderer - almBinding={mockAlmSettingsInstance()} - baseUrl="http://localhost:9000" - component={mockComponent()} - currentUser={mockLoggedInUser()} - currentUserCanScanProject={true} - loading={false} - onSelectTutorial={jest.fn()} - {...props} - /> - ); -} diff --git a/server/sonar-web/src/main/js/components/tutorials/__tests__/__snapshots__/TutorialSelection-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/__tests__/__snapshots__/TutorialSelection-test.tsx.snap deleted file mode 100644 index 6d0a8ba9332..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/__tests__/__snapshots__/TutorialSelection-test.tsx.snap +++ /dev/null @@ -1,44 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -<TutorialSelectionRenderer - baseUrl="http://host.url" - component={ - Object { - "breadcrumbs": Array [], - "key": "my-project", - "name": "MyProject", - "qualifier": "TRK", - "qualityGate": Object { - "isDefault": true, - "key": "30", - "name": "Sonar way", - }, - "qualityProfiles": Array [ - Object { - "deleted": false, - "key": "my-qp", - "language": "ts", - "name": "Sonar way", - }, - ], - "tags": Array [], - } - } - currentUser={ - Object { - "dismissedNotices": Object { - "educationPrinciples": false, - }, - "groups": Array [], - "isLoggedIn": true, - "login": "luke", - "name": "Skywalker", - "scmAccounts": Array [], - } - } - currentUserCanScanProject={false} - loading={true} - onSelectTutorial={[Function]} -/> -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/__tests__/__snapshots__/TutorialSelectionRenderer-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/__tests__/__snapshots__/TutorialSelectionRenderer-test.tsx.snap deleted file mode 100644 index 93fcf70abe1..00000000000 --- a/server/sonar-web/src/main/js/components/tutorials/__tests__/__snapshots__/TutorialSelectionRenderer-test.tsx.snap +++ /dev/null @@ -1,738 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly for azure 1`] = ` -<Fragment> - <h2 - className="spacer-top huge-spacer-bottom" - > - onboarding.tutorial.choose_method - </h2> - <div - className="tutorial-selection" - > - <p - className="big-spacer-bottom" - > - onboarding.tutorial.choose_method.devops_platform.description - </p> - <div - className="display-flex-start display-flex-wrap" - > - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-azure-pipelines" - onClick={[Function]} - type="button" - > - <img - alt="" - height={60} - src="/images/tutorials/azure-pipelines.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.azure-pipelines - </div> - </button> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-other-ci" - onClick={[Function]} - type="button" - > - <EllipsisIcon - size={60} - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.other-ci - </div> - </button> - </div> - <p - className="big-spacer-bottom spacer-top" - > - onboarding.tutorial.choose_method.local.description - </p> - <div> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-local" - onClick={[Function]} - type="button" - > - <img - alt="" - height={60} - src="/images/tutorials/manual.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.local - </div> - </button> - </div> - </div> -</Fragment> -`; - -exports[`should render correctly for bitbucket server 1`] = ` -<Fragment> - <h2 - className="spacer-top huge-spacer-bottom" - > - onboarding.tutorial.choose_method - </h2> - <div - className="tutorial-selection" - > - <p - className="big-spacer-bottom" - > - onboarding.tutorial.choose_method.devops_platform.description - </p> - <div - className="display-flex-start display-flex-wrap" - > - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-jenkins" - onClick={[Function]} - type="button" - > - <img - alt="" - height={60} - src="/images/tutorials/jenkins.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.jenkins - </div> - </button> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-other-ci" - onClick={[Function]} - type="button" - > - <EllipsisIcon - size={60} - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.other-ci - </div> - </button> - </div> - <p - className="big-spacer-bottom spacer-top" - > - onboarding.tutorial.choose_method.local.description - </p> - <div> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-local" - onClick={[Function]} - type="button" - > - <img - alt="" - height={60} - src="/images/tutorials/manual.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.local - </div> - </button> - </div> - </div> -</Fragment> -`; - -exports[`should render correctly for github 1`] = ` -<Fragment> - <h2 - className="spacer-top huge-spacer-bottom" - > - onboarding.tutorial.choose_method - </h2> - <div - className="tutorial-selection" - > - <p - className="big-spacer-bottom" - > - onboarding.tutorial.choose_method.devops_platform.description - </p> - <div - className="display-flex-start display-flex-wrap" - > - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-jenkins" - onClick={[Function]} - type="button" - > - <img - alt="" - height={60} - src="/images/tutorials/jenkins.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.jenkins - </div> - </button> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-github-actions" - onClick={[Function]} - type="button" - > - <img - alt="" - className="spacer-bottom spacer-top" - height={46} - src="/images/tutorials/github-actions.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.github-actions - </div> - </button> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-azure-pipelines" - onClick={[Function]} - type="button" - > - <img - alt="" - height={60} - src="/images/tutorials/azure-pipelines.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.azure-pipelines - </div> - </button> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-other-ci" - onClick={[Function]} - type="button" - > - <EllipsisIcon - size={60} - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.other-ci - </div> - </button> - </div> - <p - className="big-spacer-bottom spacer-top" - > - onboarding.tutorial.choose_method.local.description - </p> - <div> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-local" - onClick={[Function]} - type="button" - > - <img - alt="" - height={60} - src="/images/tutorials/manual.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.local - </div> - </button> - </div> - </div> -</Fragment> -`; - -exports[`should render correctly for gitlab 1`] = ` -<Fragment> - <h2 - className="spacer-top huge-spacer-bottom" - > - onboarding.tutorial.choose_method - </h2> - <div - className="tutorial-selection" - > - <p - className="big-spacer-bottom" - > - onboarding.tutorial.choose_method.devops_platform.description - </p> - <div - className="display-flex-start display-flex-wrap" - > - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-jenkins" - onClick={[Function]} - type="button" - > - <img - alt="" - height={60} - src="/images/tutorials/jenkins.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.jenkins - </div> - </button> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-gitlab-ci" - onClick={[Function]} - type="button" - > - <img - alt="" - height={60} - src="/images/alm/gitlab.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.gitlab-ci - </div> - </button> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-other-ci" - onClick={[Function]} - type="button" - > - <EllipsisIcon - size={60} - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.other-ci - </div> - </button> - </div> - <p - className="big-spacer-bottom spacer-top" - > - onboarding.tutorial.choose_method.local.description - </p> - <div> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-local" - onClick={[Function]} - type="button" - > - <img - alt="" - height={60} - src="/images/tutorials/manual.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.local - </div> - </button> - </div> - </div> -</Fragment> -`; - -exports[`should render correctly: azure pipelines tutorial 1`] = ` -<Fragment> - <AzurePipelinesTutorial - alm="github" - baseUrl="http://localhost:9000" - component={ - Object { - "breadcrumbs": Array [], - "key": "my-project", - "name": "MyProject", - "qualifier": "TRK", - "qualityGate": Object { - "isDefault": true, - "key": "30", - "name": "Sonar way", - }, - "qualityProfiles": Array [ - Object { - "deleted": false, - "key": "my-qp", - "language": "ts", - "name": "Sonar way", - }, - ], - "tags": Array [], - } - } - currentUser={ - Object { - "dismissedNotices": Object { - "educationPrinciples": false, - }, - "groups": Array [], - "isLoggedIn": true, - "login": "luke", - "name": "Skywalker", - "scmAccounts": Array [], - } - } - /> -</Fragment> -`; - -exports[`should render correctly: github actions tutorial 1`] = ` -<Fragment> - <GitHubActionTutorial - almBinding={ - Object { - "alm": "github", - "key": "key", - } - } - baseUrl="http://localhost:9000" - component={ - Object { - "breadcrumbs": Array [], - "key": "my-project", - "name": "MyProject", - "qualifier": "TRK", - "qualityGate": Object { - "isDefault": true, - "key": "30", - "name": "Sonar way", - }, - "qualityProfiles": Array [ - Object { - "deleted": false, - "key": "my-qp", - "language": "ts", - "name": "Sonar way", - }, - ], - "tags": Array [], - } - } - currentUser={ - Object { - "dismissedNotices": Object { - "educationPrinciples": false, - }, - "groups": Array [], - "isLoggedIn": true, - "login": "luke", - "name": "Skywalker", - "scmAccounts": Array [], - } - } - projectBinding={ - Object { - "alm": "github", - "key": "foo", - "monorepo": true, - "repository": "PROJECT_KEY", - } - } - /> -</Fragment> -`; - -exports[`should render correctly: gitlab tutorial 1`] = ` -<Fragment> - <GitLabCITutorial - baseUrl="http://localhost:9000" - component={ - Object { - "breadcrumbs": Array [], - "key": "my-project", - "name": "MyProject", - "qualifier": "TRK", - "qualityGate": Object { - "isDefault": true, - "key": "30", - "name": "Sonar way", - }, - "qualityProfiles": Array [ - Object { - "deleted": false, - "key": "my-qp", - "language": "ts", - "name": "Sonar way", - }, - ], - "tags": Array [], - } - } - currentUser={ - Object { - "dismissedNotices": Object { - "educationPrinciples": false, - }, - "groups": Array [], - "isLoggedIn": true, - "login": "luke", - "name": "Skywalker", - "scmAccounts": Array [], - } - } - /> -</Fragment> -`; - -exports[`should render correctly: jenkins tutorial 1`] = ` -<Fragment> - <withAvailableFeaturesContext(JenkinsTutorial) - almBinding={ - Object { - "alm": "github", - "key": "key", - } - } - baseUrl="http://localhost:9000" - component={ - Object { - "breadcrumbs": Array [], - "key": "my-project", - "name": "MyProject", - "qualifier": "TRK", - "qualityGate": Object { - "isDefault": true, - "key": "30", - "name": "Sonar way", - }, - "qualityProfiles": Array [ - Object { - "deleted": false, - "key": "my-qp", - "language": "ts", - "name": "Sonar way", - }, - ], - "tags": Array [], - } - } - projectBinding={ - Object { - "alm": "bitbucket", - "key": "foo", - "monorepo": true, - "repository": "PROJECT_KEY", - "slug": "repo-slug", - } - } - /> -</Fragment> -`; - -exports[`should render correctly: loading 1`] = ` -<i - className="spinner" -/> -`; - -exports[`should render correctly: manual tutorial 1`] = ` -<Fragment> - <OtherTutorial - baseUrl="http://localhost:9000" - component={ - Object { - "breadcrumbs": Array [], - "key": "my-project", - "name": "MyProject", - "qualifier": "TRK", - "qualityGate": Object { - "isDefault": true, - "key": "30", - "name": "Sonar way", - }, - "qualityProfiles": Array [ - Object { - "deleted": false, - "key": "my-qp", - "language": "ts", - "name": "Sonar way", - }, - ], - "tags": Array [], - } - } - currentUser={ - Object { - "dismissedNotices": Object { - "educationPrinciples": false, - }, - "groups": Array [], - "isLoggedIn": true, - "login": "luke", - "name": "Skywalker", - "scmAccounts": Array [], - } - } - isLocal={true} - /> -</Fragment> -`; - -exports[`should render correctly: selection 1`] = ` -<Fragment> - <h2 - className="spacer-top huge-spacer-bottom" - > - onboarding.tutorial.choose_method - </h2> - <div - className="tutorial-selection" - > - <p - className="big-spacer-bottom" - > - onboarding.tutorial.choose_method.devops_platform.description - </p> - <div - className="display-flex-start display-flex-wrap" - > - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-jenkins" - onClick={[Function]} - type="button" - > - <img - alt="" - height={60} - src="/images/tutorials/jenkins.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.jenkins - </div> - </button> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-github-actions" - onClick={[Function]} - type="button" - > - <img - alt="" - className="spacer-bottom spacer-top" - height={46} - src="/images/tutorials/github-actions.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.github-actions - </div> - </button> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-bitbucket-pipelines" - onClick={[Function]} - type="button" - > - <img - alt="" - height={60} - src="/images/alm/bitbucket.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.bitbucket-pipelines - </div> - </button> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-gitlab-ci" - onClick={[Function]} - type="button" - > - <img - alt="" - height={60} - src="/images/alm/gitlab.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.gitlab-ci - </div> - </button> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-azure-pipelines" - onClick={[Function]} - type="button" - > - <img - alt="" - height={60} - src="/images/tutorials/azure-pipelines.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.azure-pipelines - </div> - </button> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-other-ci" - onClick={[Function]} - type="button" - > - <EllipsisIcon - size={60} - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.other-ci - </div> - </button> - </div> - <p - className="big-spacer-bottom spacer-top" - > - onboarding.tutorial.choose_method.local.description - </p> - <div> - <button - className="button button-huge display-flex-column big-spacer-right big-spacer-bottom tutorial-mode-local" - onClick={[Function]} - type="button" - > - <img - alt="" - height={60} - src="/images/tutorials/manual.svg" - /> - <div - className="medium big-spacer-top" - > - onboarding.tutorial.choose_method.local - </div> - </button> - </div> - </div> -</Fragment> -`; - -exports[`should render correctly: user has no scan permission 1`] = ` -<Alert - variant="warning" -> - onboarding.tutorial.no_scan_rights -</Alert> -`; diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx index 256d7592b46..823ad58c8b9 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/AnalysisCommand.tsx @@ -32,12 +32,13 @@ import Others from './commands/Others'; export interface AnalysisCommandProps extends WithAvailableFeaturesProps { buildTool: BuildTools; + mainBranchName: string; component: Component; onDone: () => void; } export function AnalysisCommand(props: AnalysisCommandProps) { - const { buildTool, component } = props; + const { buildTool, component, mainBranchName } = props; const branchSupportEnabled = props.hasFeature(Feature.BranchSupport); if (!buildTool) { @@ -49,6 +50,7 @@ export function AnalysisCommand(props: AnalysisCommandProps) { return ( <JavaMaven branchesEnabled={branchSupportEnabled} + mainBranchName={mainBranchName} component={component} onDone={props.onDone} /> @@ -57,6 +59,7 @@ export function AnalysisCommand(props: AnalysisCommandProps) { return ( <Gradle branchesEnabled={branchSupportEnabled} + mainBranchName={mainBranchName} component={component} onDone={props.onDone} /> @@ -65,6 +68,7 @@ export function AnalysisCommand(props: AnalysisCommandProps) { return ( <DotNet branchesEnabled={branchSupportEnabled} + mainBranchName={mainBranchName} component={component} onDone={props.onDone} /> @@ -73,6 +77,7 @@ export function AnalysisCommand(props: AnalysisCommandProps) { return ( <CFamily branchesEnabled={branchSupportEnabled} + mainBranchName={mainBranchName} component={component} onDone={props.onDone} /> @@ -81,12 +86,12 @@ export function AnalysisCommand(props: AnalysisCommandProps) { return ( <Others branchesEnabled={branchSupportEnabled} + mainBranchName={mainBranchName} component={component} onDone={props.onDone} /> ); } - return null; } export default withAvailableFeatures(AnalysisCommand); diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx index efa89c8d623..64a8ffd6e6c 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx @@ -43,6 +43,7 @@ export interface GitHubActionTutorialProps { baseUrl: string; component: Component; currentUser: LoggedInUser; + mainBranchName: string; projectBinding?: ProjectAlmBindingResponse; willRefreshAutomatically?: boolean; } @@ -54,6 +55,7 @@ export default function GitHubActionTutorial(props: GitHubActionTutorialProps) { currentUser, component, projectBinding, + mainBranchName, willRefreshAutomatically } = props; @@ -86,6 +88,7 @@ export default function GitHubActionTutorial(props: GitHubActionTutorialProps) { {buildTool => ( <AnalysisCommand buildTool={buildTool} + mainBranchName={mainBranchName} component={component} onDone={() => setStep(Steps.ALL_SET)} /> diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/AnalysisCommand-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/AnalysisCommand-test.tsx index eeb4667d1f8..47f444fdd9c 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/AnalysisCommand-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/AnalysisCommand-test.tsx @@ -38,6 +38,7 @@ function shallowRender(props: Partial<AnalysisCommandProps> = {}) { return shallow<AnalysisCommandProps>( <AnalysisCommand hasFeature={jest.fn().mockReturnValue(false)} + mainBranchName="main" component={mockComponent()} buildTool={BuildTools.DotNet} onDone={jest.fn()} diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GitHubActionTutorial-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GitHubActionTutorial-test.tsx index 25a51c4036a..e0bde53be19 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GitHubActionTutorial-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GitHubActionTutorial-test.tsx @@ -77,6 +77,7 @@ function shallowRender(props: Partial<GitHubActionTutorialProps> = {}) { baseUrl="test" currentUser={mockLoggedInUser()} component={mockComponent()} + mainBranchName="master" projectBinding={mockProjectGithubBindingResponse()} willRefreshAutomatically={true} {...props} diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap index 5543105efd6..01a9adb6013 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap @@ -25,6 +25,7 @@ exports[`should render correctly for "cfamily" 1`] = ` "tags": Array [], } } + mainBranchName="main" onDone={[MockFunction]} /> `; @@ -54,6 +55,7 @@ exports[`should render correctly for "dotnet" 1`] = ` "tags": Array [], } } + mainBranchName="main" onDone={[MockFunction]} /> `; @@ -83,6 +85,7 @@ exports[`should render correctly for "gradle" 1`] = ` "tags": Array [], } } + mainBranchName="main" onDone={[MockFunction]} /> `; @@ -112,6 +115,7 @@ exports[`should render correctly for "maven" 1`] = ` "tags": Array [], } } + mainBranchName="main" onDone={[MockFunction]} /> `; @@ -141,6 +145,7 @@ exports[`should render correctly for "other" 1`] = ` "tags": Array [], } } + mainBranchName="main" onDone={[MockFunction]} /> `; diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/CFamily.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/CFamily.tsx index c6e3e5bd27f..bccaf877ee4 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/CFamily.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/CFamily.tsx @@ -27,20 +27,17 @@ import FinishButton from '../../components/FinishButton'; import GithubCFamilyExampleRepositories from '../../components/GithubCFamilyExampleRepositories'; import RenderOptions from '../../components/RenderOptions'; import { OSs, TutorialModes } from '../../types'; +import { generateGitHubActionsYaml } from '../utils'; export interface CFamilyProps { branchesEnabled?: boolean; + mainBranchName: string; component: Component; onDone: () => void; } const STEPS = { - [OSs.Linux]: `steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - + [OSs.Linux]: ` - name: Download and install the build wrapper, build the project run: | mkdir $HOME/.sonar @@ -64,12 +61,7 @@ const STEPS = { env: SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}`, - [OSs.MacOS]: `steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - + [OSs.MacOS]: ` - name: Download and install the build wrapper run: | mkdir $HOME/.sonar @@ -91,12 +83,7 @@ const STEPS = { env: SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}`, - [OSs.Windows]: `steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - + [OSs.Windows]: ` - name: Download and install the build wrapper shell: powershell run: | @@ -129,21 +116,8 @@ const STEPS = { SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}` }; -const cfamilyYamlTemplate = (branchesEnabled: boolean, os: OSs) => `name: Build -on: - push: - branches: - - master # or the name of your main branch -${branchesEnabled ? ' pull_request:\n types: [opened, synchronize, reopened]' : ''} - -jobs: - build: - runs-on: <image ready for your build toolchain> - ${STEPS[os]} -`; - export default function CFamily(props: CFamilyProps) { - const { component, branchesEnabled } = props; + const { component, branchesEnabled, mainBranchName } = props; const [os, setOs] = React.useState<undefined | OSs>(); return ( @@ -170,7 +144,12 @@ export default function CFamily(props: CFamilyProps) { <> <CreateYmlFile yamlFileName=".github/workflows/build.yml" - yamlTemplate={cfamilyYamlTemplate(!!branchesEnabled, os)} + yamlTemplate={generateGitHubActionsYaml( + mainBranchName, + !!branchesEnabled, + '<image ready for your build toolchain>', + STEPS[os] + )} /> <CompilationInfo className="abs-width-800" /> <FinishButton onClick={props.onDone} /> diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/DotNet.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/DotNet.tsx index 810d1236eb1..3a09a7e28e8 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/DotNet.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/DotNet.tsx @@ -21,31 +21,22 @@ import * as React from 'react'; import { Component } from '../../../../types/types'; import CreateYmlFile from '../../components/CreateYmlFile'; import FinishButton from '../../components/FinishButton'; +import { GITHUB_ACTIONS_RUNS_ON_WINDOWS } from '../constants'; +import { generateGitHubActionsYaml } from '../utils'; export interface DotNetProps { branchesEnabled?: boolean; + mainBranchName: string; component: Component; onDone: () => void; } -const dotnetYamlTemplate = (projectKey: string, branchesEnabled: boolean) => `name: Build -on: - push: - branches: - - master # or the name of your main branch -${branchesEnabled ? ' pull_request:\n types: [opened, synchronize, reopened]' : ''} -jobs: - build: - name: Build - runs-on: windows-latest - steps: +function dotnetYamlSteps(projectKey: string) { + return ` - name: Set up JDK 11 uses: actions/setup-java@v1 with: java-version: 1.11 - - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Cache SonarQube packages uses: actions/cache@v1 with: @@ -73,14 +64,20 @@ jobs: .\\.sonar\\scanner\\dotnet-sonarscanner begin /k:"${projectKey}" /d:sonar.login="\${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="\${{ secrets.SONAR_HOST_URL }}" dotnet build .\\.sonar\\scanner\\dotnet-sonarscanner end /d:sonar.login="\${{ secrets.SONAR_TOKEN }}"`; +} export default function DotNet(props: DotNetProps) { - const { component, branchesEnabled } = props; + const { component, branchesEnabled, mainBranchName } = props; return ( <> <CreateYmlFile yamlFileName=".github/workflows/build.yml" - yamlTemplate={dotnetYamlTemplate(component.key, !!branchesEnabled)} + yamlTemplate={generateGitHubActionsYaml( + mainBranchName, + !!branchesEnabled, + GITHUB_ACTIONS_RUNS_ON_WINDOWS, + dotnetYamlSteps(component.key) + )} /> <FinishButton onClick={props.onDone} /> </> diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Gradle.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Gradle.tsx index 4d76a483c3d..e2b8d44eb67 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Gradle.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Gradle.tsx @@ -26,26 +26,17 @@ import CodeSnippet from '../../../common/CodeSnippet'; import CreateYmlFile from '../../components/CreateYmlFile'; import FinishButton from '../../components/FinishButton'; import { buildGradleSnippet } from '../../utils'; +import { GITHUB_ACTIONS_RUNS_ON_LINUX } from '../constants'; +import { generateGitHubActionsYaml } from '../utils'; export interface GradleProps { branchesEnabled?: boolean; + mainBranchName: string; component: Component; onDone: () => void; } -const gradleYamlTemplate = (branchesEnabled: boolean) => `name: Build -on: - push: - branches: - - master # or the name of your main branch -${branchesEnabled ? ' pull_request:\n types: [opened, synchronize, reopened]' : ''} -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + +const GRADLE_YAML_STEPS = ` - name: Set up JDK 11 uses: actions/setup-java@v1 with: @@ -70,7 +61,7 @@ jobs: run: ./gradlew build sonarqube --info`; export default function Gradle(props: GradleProps) { - const { component, branchesEnabled } = props; + const { component, branchesEnabled, mainBranchName } = props; return ( <> @@ -92,7 +83,12 @@ export default function Gradle(props: GradleProps) { </li> <CreateYmlFile yamlFileName=".github/workflows/build.yml" - yamlTemplate={gradleYamlTemplate(!!branchesEnabled)} + yamlTemplate={generateGitHubActionsYaml( + mainBranchName, + !!branchesEnabled, + GITHUB_ACTIONS_RUNS_ON_LINUX, + GRADLE_YAML_STEPS + )} /> <FinishButton onClick={props.onDone} /> </> diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/JavaMaven.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/JavaMaven.tsx index a3c69da85fa..706f66d27df 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/JavaMaven.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/JavaMaven.tsx @@ -21,27 +21,18 @@ import * as React from 'react'; import { Component } from '../../../../types/types'; import CreateYmlFile from '../../components/CreateYmlFile'; import FinishButton from '../../components/FinishButton'; +import { GITHUB_ACTIONS_RUNS_ON_LINUX } from '../constants'; +import { generateGitHubActionsYaml } from '../utils'; export interface JavaMavenProps { branchesEnabled?: boolean; + mainBranchName: string; component: Component; onDone: () => void; } -const mavenYamlTemplte = (branchesEnabled: boolean, projectKey: string) => `name: Build -on: - push: - branches: - - master # or the name of your main branch -${branchesEnabled ? ' pull_request:\n types: [opened, synchronize, reopened]' : ''} -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis +function mavenYamlSteps(projectKey: string) { + return ` - name: Set up JDK 11 uses: actions/setup-java@v1 with: @@ -64,14 +55,20 @@ jobs: SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }} run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=${projectKey}`; +} export default function JavaMaven(props: JavaMavenProps) { - const { component, branchesEnabled } = props; + const { component, branchesEnabled, mainBranchName } = props; return ( <> <CreateYmlFile yamlFileName=".github/workflows/build.yml" - yamlTemplate={mavenYamlTemplte(!!branchesEnabled, component.key)} + yamlTemplate={generateGitHubActionsYaml( + mainBranchName, + !!branchesEnabled, + GITHUB_ACTIONS_RUNS_ON_LINUX, + mavenYamlSteps(component.key) + )} /> <FinishButton onClick={props.onDone} /> </> diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Others.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Others.tsx index 3d0d3825886..b100b775993 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Others.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Others.tsx @@ -22,35 +22,18 @@ import { Component } from '../../../../types/types'; import CreateYmlFile from '../../components/CreateYmlFile'; import DefaultProjectKey from '../../components/DefaultProjectKey'; import FinishButton from '../../components/FinishButton'; +import { GITHUB_ACTIONS_RUNS_ON_LINUX } from '../constants'; +import { generateGitHubActionsYaml } from '../utils'; export interface OthersProps { branchesEnabled?: boolean; + mainBranchName: string; component: Component; onDone: () => void; } -const yamlTemplate = (branchesEnabled: boolean) => { - let output = `name: Build -on: - push: - branches: - - master # or the name of your main branch`; - - if (branchesEnabled) { - output += ` - pull_request: - types: [opened, synchronize, reopened]`; - } - - output += ` -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 +function otherYamlSteps(branchesEnabled: boolean) { + let output = ` - uses: sonarsource/sonarqube-scan-action@master env: SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} @@ -71,16 +54,21 @@ jobs: # SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }}`; return output; -}; +} export default function Others(props: OthersProps) { - const { component, branchesEnabled } = props; + const { component, branchesEnabled, mainBranchName } = props; return ( <> <DefaultProjectKey component={component} /> <CreateYmlFile yamlFileName=".github/workflows/build.yml" - yamlTemplate={yamlTemplate(!!branchesEnabled)} + yamlTemplate={generateGitHubActionsYaml( + mainBranchName, + !!branchesEnabled, + GITHUB_ACTIONS_RUNS_ON_LINUX, + otherYamlSteps(!!branchesEnabled) + )} /> <FinishButton onClick={props.onDone} /> </> diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/CFamily-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/CFamily-test.tsx index 2bbbdf8fd09..dc4ea5ec120 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/CFamily-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/CFamily-test.tsx @@ -43,6 +43,12 @@ it.each([ function shallowRender(props: Partial<CFamilyProps> = {}) { return shallow<CFamilyProps>( - <CFamily branchesEnabled={true} component={mockComponent()} {...props} onDone={jest.fn()} /> + <CFamily + branchesEnabled={true} + component={mockComponent()} + mainBranchName="main" + onDone={jest.fn()} + {...props} + /> ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/DotNet-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/DotNet-test.tsx index 85372435783..1dc3811dc32 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/DotNet-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/DotNet-test.tsx @@ -29,6 +29,12 @@ it('should render correctly', () => { function shallowRender(props: Partial<DotNetProps> = {}) { return shallow<DotNetProps>( - <DotNet branchesEnabled={true} component={mockComponent()} {...props} onDone={jest.fn()} /> + <DotNet + branchesEnabled={true} + component={mockComponent()} + mainBranchName="main" + {...props} + onDone={jest.fn()} + /> ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/Gradle-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/Gradle-test.tsx index 0c9448ce285..a52cbb5d2f6 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/Gradle-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/Gradle-test.tsx @@ -29,6 +29,12 @@ it('should render correctly', () => { function shallowRender(props: Partial<GradleProps> = {}) { return shallow<GradleProps>( - <Gradle branchesEnabled={true} component={mockComponent()} {...props} onDone={jest.fn()} /> + <Gradle + branchesEnabled={true} + component={mockComponent()} + mainBranchName="main" + onDone={jest.fn()} + {...props} + /> ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/JavaMaven-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/JavaMaven-test.tsx index 3eee022fe76..a042cedc600 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/JavaMaven-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/JavaMaven-test.tsx @@ -29,6 +29,12 @@ it('should render correctly', () => { function shallowRender(props: Partial<JavaMavenProps> = {}) { return shallow<JavaMavenProps>( - <JavaMaven branchesEnabled={true} component={mockComponent()} {...props} onDone={jest.fn()} /> + <JavaMaven + branchesEnabled={true} + component={mockComponent()} + mainBranchName="main" + onDone={jest.fn()} + {...props} + /> ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/Others-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/Others-test.tsx index 1b4212ead6b..48b464822db 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/Others-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/Others-test.tsx @@ -29,6 +29,12 @@ it('should render correctly', () => { function shallowRender(props: Partial<OthersProps> = {}) { return shallow<OthersProps>( - <Others branchesEnabled={true} component={mockComponent()} {...props} onDone={jest.fn()} /> + <Others + branchesEnabled={true} + component={mockComponent()} + mainBranchName="main" + onDone={jest.fn()} + {...props} + /> ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/CFamily-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/CFamily-test.tsx.snap index 0bb3b8961db..15eeaf5e46e 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/CFamily-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/CFamily-test.tsx.snap @@ -102,21 +102,21 @@ exports[`should render correctly for linux: branches disabled 1`] = ` <CreateYmlFile yamlFileName=".github/workflows/build.yml" yamlTemplate="name: Build + on: push: branches: - - master # or the name of your main branch + - main jobs: build: + name: Build runs-on: <image ready for your build toolchain> steps: - - name: Checkout code - uses: actions/checkout@v2 + - uses: actions/checkout@v2 with: - fetch-depth: 0 - + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Download and install the build wrapper, build the project run: | mkdir $HOME/.sonar @@ -139,8 +139,7 @@ jobs: sonar-scanner --define sonar.cfamily.build-wrapper-output=bw-output env: SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }} -" + SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}" /> <CompilationInfo className="abs-width-800" @@ -205,22 +204,22 @@ exports[`should render correctly for mac: branches enabled 1`] = ` <CreateYmlFile yamlFileName=".github/workflows/build.yml" yamlTemplate="name: Build + on: push: branches: - - master # or the name of your main branch + - main pull_request: types: [opened, synchronize, reopened] jobs: build: + name: Build runs-on: <image ready for your build toolchain> steps: - - name: Checkout code - uses: actions/checkout@v2 + - uses: actions/checkout@v2 with: - fetch-depth: 0 - + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Download and install the build wrapper run: | mkdir $HOME/.sonar @@ -241,8 +240,7 @@ jobs: $HOME/.sonar/sonar-scanner-4.6.2.2472-macosx/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output env: SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }} -" + SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}" /> <CompilationInfo className="abs-width-800" @@ -307,22 +305,22 @@ exports[`should render correctly for win: branches enabled 1`] = ` <CreateYmlFile yamlFileName=".github/workflows/build.yml" yamlTemplate="name: Build + on: push: branches: - - master # or the name of your main branch + - main pull_request: types: [opened, synchronize, reopened] jobs: build: + name: Build runs-on: <image ready for your build toolchain> steps: - - name: Checkout code - uses: actions/checkout@v2 + - uses: actions/checkout@v2 with: - fetch-depth: 0 - + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Download and install the build wrapper shell: powershell run: | @@ -352,8 +350,7 @@ jobs: sonar-scanner.bat \\"-Dsonar.cfamily.build-wrapper-output=bw-output\\" env: SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }} -" + SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}" /> <CompilationInfo className="abs-width-800" diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/DotNet-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/DotNet-test.tsx.snap index 3e0e44b10de..485c8da4d80 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/DotNet-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/DotNet-test.tsx.snap @@ -5,24 +5,26 @@ exports[`should render correctly 1`] = ` <CreateYmlFile yamlFileName=".github/workflows/build.yml" yamlTemplate="name: Build + on: push: branches: - - master # or the name of your main branch + - main pull_request: types: [opened, synchronize, reopened] + jobs: build: name: Build runs-on: windows-latest steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Set up JDK 11 uses: actions/setup-java@v1 with: java-version: 1.11 - - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Cache SonarQube packages uses: actions/cache@v1 with: @@ -62,23 +64,25 @@ exports[`should render correctly: without branch enabled 1`] = ` <CreateYmlFile yamlFileName=".github/workflows/build.yml" yamlTemplate="name: Build + on: push: branches: - - master # or the name of your main branch + - main + jobs: build: name: Build runs-on: windows-latest steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Set up JDK 11 uses: actions/setup-java@v1 with: java-version: 1.11 - - uses: actions/checkout@v2 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Cache SonarQube packages uses: actions/cache@v1 with: diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Gradle-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Gradle-test.tsx.snap index 04dcf26e29c..9cf9e7c5967 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Gradle-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Gradle-test.tsx.snap @@ -43,12 +43,14 @@ sonarqube { <CreateYmlFile yamlFileName=".github/workflows/build.yml" yamlTemplate="name: Build + on: push: branches: - - master # or the name of your main branch + - main pull_request: types: [opened, synchronize, reopened] + jobs: build: name: Build @@ -129,10 +131,12 @@ sonarqube { <CreateYmlFile yamlFileName=".github/workflows/build.yml" yamlTemplate="name: Build + on: push: branches: - - master # or the name of your main branch + - main + jobs: build: diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/JavaMaven-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/JavaMaven-test.tsx.snap index 766cf60eb73..c26604e439e 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/JavaMaven-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/JavaMaven-test.tsx.snap @@ -5,12 +5,14 @@ exports[`should render correctly 1`] = ` <CreateYmlFile yamlFileName=".github/workflows/build.yml" yamlTemplate="name: Build + on: push: branches: - - master # or the name of your main branch + - main pull_request: types: [opened, synchronize, reopened] + jobs: build: name: Build @@ -53,10 +55,12 @@ exports[`should render correctly: without branch enabled 1`] = ` <CreateYmlFile yamlFileName=".github/workflows/build.yml" yamlTemplate="name: Build + on: push: branches: - - master # or the name of your main branch + - main + jobs: build: diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Others-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Others-test.tsx.snap index 6ecc6c79c53..5c063040760 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Others-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Others-test.tsx.snap @@ -29,12 +29,14 @@ exports[`should render correctly 1`] = ` <CreateYmlFile yamlFileName=".github/workflows/build.yml" yamlTemplate="name: Build + on: push: branches: - - master # or the name of your main branch + - main pull_request: types: [opened, synchronize, reopened] + jobs: build: name: Build @@ -42,7 +44,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - fetch-depth: 0 + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - uses: sonarsource/sonarqube-scan-action@master env: SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} @@ -91,10 +93,13 @@ exports[`should render correctly: without branch enabled 1`] = ` <CreateYmlFile yamlFileName=".github/workflows/build.yml" yamlTemplate="name: Build + on: push: branches: - - master # or the name of your main branch + - main + + jobs: build: name: Build @@ -102,7 +107,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - fetch-depth: 0 + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - uses: sonarsource/sonarqube-scan-action@master env: SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/constants.ts b/server/sonar-web/src/main/js/components/tutorials/github-action/constants.ts new file mode 100644 index 00000000000..2f96d518aa3 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/constants.ts @@ -0,0 +1,21 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 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. + */ +export const GITHUB_ACTIONS_RUNS_ON_LINUX = 'ubuntu-latest'; +export const GITHUB_ACTIONS_RUNS_ON_WINDOWS = 'windows-latest'; diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/utils.ts b/server/sonar-web/src/main/js/components/tutorials/github-action/utils.ts new file mode 100644 index 00000000000..a0240830693 --- /dev/null +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/utils.ts @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 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. + */ +export function generateGitHubActionsYaml( + mainBranchName: string, + branchesEnabled: boolean, + runsOn: string, + steps: string +) { + return `name: Build + +on: + push: + branches: + - ${mainBranchName} +${branchesEnabled ? ' pull_request:\n types: [opened, synchronize, reopened]' : ''} + +jobs: + build: + name: Build + runs-on: ${runsOn} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis${steps}`; +} diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/GitLabCITutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/GitLabCITutorial.tsx index d1c7291d9b3..2c114176b9a 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/GitLabCITutorial.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/GitLabCITutorial.tsx @@ -39,11 +39,12 @@ export interface GitLabCITutorialProps { baseUrl: string; component: Component; currentUser: LoggedInUser; + mainBranchName: string; willRefreshAutomatically?: boolean; } export default function GitLabCITutorial(props: GitLabCITutorialProps) { - const { baseUrl, component, currentUser, willRefreshAutomatically } = props; + const { baseUrl, component, currentUser, willRefreshAutomatically, mainBranchName } = props; const [step, setStep] = React.useState(Steps.PROJECT_KEY); const [buildTool, setBuildTool] = React.useState<BuildTools>(); @@ -77,6 +78,7 @@ export default function GitLabCITutorial(props: GitLabCITutorialProps) { <YmlFileStep buildTool={buildTool} finished={step > Steps.YML} + mainBranchName={mainBranchName} onDone={() => setStep(Steps.ALL_SET)} onOpen={() => setStep(Steps.YML)} open={step === Steps.YML} diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/ProjectKeyStep.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/ProjectKeyStep.tsx index df7bcb7b2de..3c3c4970eba 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/ProjectKeyStep.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/ProjectKeyStep.tsx @@ -21,6 +21,7 @@ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { Button } from '../../../components/controls/buttons'; import { ClipboardIconButton } from '../../../components/controls/clipboard'; +import { GRADLE_SCANNER_VERSION } from '../../../helpers/constants'; import { translate } from '../../../helpers/l10n'; import { Component } from '../../../types/types'; import CodeSnippet from '../../common/CodeSnippet'; @@ -45,7 +46,7 @@ const mavenSnippet = () => `<properties> </properties>`; const gradleSnippet = (key: string) => `plugins { - id "org.sonarqube" version "3.4.0.2513" + id "org.sonarqube" version "${GRADLE_SCANNER_VERSION}" } sonarqube { diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx index af9f96dc8c4..9d38b844385 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/YmlFileStep.tsx @@ -38,10 +38,11 @@ export interface YmlFileStepProps extends WithAvailableFeaturesProps { onOpen: () => void; open: boolean; projectKey: string; + mainBranchName: string; } export function YmlFileStep(props: YmlFileStepProps) { - const { buildTool, open, finished, projectKey } = props; + const { buildTool, open, finished, projectKey, mainBranchName } = props; const branchSupportEnabled = props.hasFeature(Feature.BranchSupport); const renderForm = () => ( @@ -79,6 +80,7 @@ export function YmlFileStep(props: YmlFileStepProps) { <PipeCommand buildTool={buildTool} branchesEnabled={branchSupportEnabled} + mainBranchName={mainBranchName} projectKey={projectKey} /> </div> diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/GitLabCITutorial-test.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/GitLabCITutorial-test.tsx index a5b34b50822..49baf473898 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/GitLabCITutorial-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/GitLabCITutorial-test.tsx @@ -33,6 +33,7 @@ function shallowRender(props: Partial<GitLabCITutorialProps> = {}) { baseUrl="http://localhost:9000" component={mockComponent()} currentUser={mockLoggedInUser()} + mainBranchName="main" willRefreshAutomatically={true} {...props} /> diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/YmlFileStep-test.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/YmlFileStep-test.tsx index 9c6b0614afa..ac93bffa6cf 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/YmlFileStep-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/YmlFileStep-test.tsx @@ -49,6 +49,7 @@ function shallowRender(props: Partial<YmlFileStepProps> = {}) { open={true} projectKey="test" finished={true} + mainBranchName="main" onDone={jest.fn()} onOpen={jest.fn()} {...props} diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-test.tsx.snap index d3fc71fa399..5d6322ac43e 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-test.tsx.snap @@ -83,6 +83,7 @@ exports[`should render correctly 1`] = ` /> <withAvailableFeaturesContext(YmlFileStep) finished={false} + mainBranchName="main" onDone={[Function]} onOpen={[Function]} open={false} diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/YmlFileStep-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/YmlFileStep-test.tsx.snap index 7ac6df811c5..24bb911d84a 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/YmlFileStep-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/YmlFileStep-test.tsx.snap @@ -44,6 +44,7 @@ exports[`should render correctly for build tool cfamily: with branch support 1`] <PipeCommand branchesEnabled={true} buildTool="cfamily" + mainBranchName="main" projectKey="test" /> </div> @@ -108,6 +109,7 @@ exports[`should render correctly for build tool cfamily: without branch support <PipeCommand branchesEnabled={false} buildTool="cfamily" + mainBranchName="main" projectKey="test" /> </div> @@ -168,6 +170,7 @@ exports[`should render correctly for build tool dotnet: with branch support 1`] <PipeCommand branchesEnabled={true} buildTool="dotnet" + mainBranchName="main" projectKey="test" /> </div> @@ -228,6 +231,7 @@ exports[`should render correctly for build tool dotnet: without branch support 1 <PipeCommand branchesEnabled={false} buildTool="dotnet" + mainBranchName="main" projectKey="test" /> </div> @@ -288,6 +292,7 @@ exports[`should render correctly for build tool gradle: with branch support 1`] <PipeCommand branchesEnabled={true} buildTool="gradle" + mainBranchName="main" projectKey="test" /> </div> @@ -348,6 +353,7 @@ exports[`should render correctly for build tool gradle: without branch support 1 <PipeCommand branchesEnabled={false} buildTool="gradle" + mainBranchName="main" projectKey="test" /> </div> @@ -408,6 +414,7 @@ exports[`should render correctly for build tool maven: with branch support 1`] = <PipeCommand branchesEnabled={true} buildTool="maven" + mainBranchName="main" projectKey="test" /> </div> @@ -468,6 +475,7 @@ exports[`should render correctly for build tool maven: without branch support 1` <PipeCommand branchesEnabled={false} buildTool="maven" + mainBranchName="main" projectKey="test" /> </div> @@ -528,6 +536,7 @@ exports[`should render correctly for build tool other: with branch support 1`] = <PipeCommand branchesEnabled={true} buildTool="other" + mainBranchName="main" projectKey="test" /> </div> @@ -588,6 +597,7 @@ exports[`should render correctly for build tool other: without branch support 1` <PipeCommand branchesEnabled={false} buildTool="other" + mainBranchName="main" projectKey="test" /> </div> diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/PipeCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/PipeCommand.tsx index 9b78795ed09..4202cb2cd51 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/PipeCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/PipeCommand.tsx @@ -25,6 +25,7 @@ import { BuildTools } from '../../types'; export interface PipeCommandProps { branchesEnabled?: boolean; buildTool: BuildTools; + mainBranchName: string; projectKey: string; } @@ -55,7 +56,8 @@ const BUILD_TOOL_SPECIFIC = { } }; -export default function PipeCommand({ projectKey, branchesEnabled, buildTool }: PipeCommandProps) { +export default function PipeCommand(props: PipeCommandProps) { + const { projectKey, branchesEnabled, buildTool, mainBranchName } = props; let command: string; if (buildTool === BuildTools.CFamily) { command = `image: <image ready for your build toolchain> @@ -91,9 +93,9 @@ sonarqube-check: } else { const onlyBlock = branchesEnabled ? `- merge_requests - - master # or the name of your main branch + - ${mainBranchName} - develop` - : '- master # or the name of your main branch'; + : `- ${mainBranchName}`; const { image, script } = BUILD_TOOL_SPECIFIC[buildTool]; diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/__tests__/PipeCommand-test.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/__tests__/PipeCommand-test.tsx index 1542dd14cf2..0304f125f47 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/__tests__/PipeCommand-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/__tests__/PipeCommand-test.tsx @@ -30,9 +30,23 @@ it.each([ [BuildTools.Other] ])('should render correctly for %s', buildTool => { expect( - shallow(<PipeCommand buildTool={buildTool} branchesEnabled={true} projectKey="test" />) + shallow( + <PipeCommand + buildTool={buildTool} + branchesEnabled={true} + mainBranchName="main" + projectKey="test" + /> + ) ).toMatchSnapshot('branches enabled'); expect( - shallow(<PipeCommand buildTool={buildTool} branchesEnabled={true} projectKey="test" />) + shallow( + <PipeCommand + buildTool={buildTool} + branchesEnabled={true} + mainBranchName="main" + projectKey="test" + /> + ) ).toMatchSnapshot('branches not enabled'); }); diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/__tests__/__snapshots__/PipeCommand-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/__tests__/__snapshots__/PipeCommand-test.tsx.snap index 94a01df480b..9b66a6ec41e 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/__tests__/__snapshots__/PipeCommand-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/__tests__/__snapshots__/PipeCommand-test.tsx.snap @@ -99,7 +99,7 @@ exports[`should render correctly for dotnet: branches enabled 1`] = ` allow_failure: true only: - merge_requests - - master # or the name of your main branch + - main - develop " /> @@ -129,7 +129,7 @@ exports[`should render correctly for dotnet: branches not enabled 1`] = ` allow_failure: true only: - merge_requests - - master # or the name of your main branch + - main - develop " /> @@ -152,7 +152,7 @@ exports[`should render correctly for gradle: branches enabled 1`] = ` allow_failure: true only: - merge_requests - - master # or the name of your main branch + - main - develop " /> @@ -175,7 +175,7 @@ exports[`should render correctly for gradle: branches not enabled 1`] = ` allow_failure: true only: - merge_requests - - master # or the name of your main branch + - main - develop " /> @@ -199,7 +199,7 @@ exports[`should render correctly for maven: branches enabled 1`] = ` allow_failure: true only: - merge_requests - - master # or the name of your main branch + - main - develop " /> @@ -223,7 +223,7 @@ exports[`should render correctly for maven: branches not enabled 1`] = ` allow_failure: true only: - merge_requests - - master # or the name of your main branch + - main - develop " /> @@ -249,7 +249,7 @@ exports[`should render correctly for other: branches enabled 1`] = ` allow_failure: true only: - merge_requests - - master # or the name of your main branch + - main - develop " /> @@ -275,7 +275,7 @@ exports[`should render correctly for other: branches not enabled 1`] = ` allow_failure: true only: - merge_requests - - master # or the name of your main branch + - main - develop " /> diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/AnalysisCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/AnalysisCommand.tsx index 3b47235be27..1f94552c9e3 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/AnalysisCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/AnalysisCommand.tsx @@ -18,7 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import { getHostUrl } from '../../../../helpers/urls'; import { Component } from '../../../../types/types'; import { BuildTools, ManualTutorialConfig } from '../../types'; import ClangGCCCustom from './ClangGCCCommand'; @@ -42,24 +41,21 @@ export default function AnalysisCommand(props: AnalysisCommandProps) { return null; } - const host = getHostUrl(); - switch (languageConfig.buildTool) { case BuildTools.Maven: - return <JavaMaven host={host} component={component} token={token} />; + return <JavaMaven baseUrl={baseUrl} component={component} token={token} />; case BuildTools.Gradle: - return <JavaGradle host={host} component={component} token={token} />; + return <JavaGradle baseUrl={baseUrl} component={component} token={token} />; case BuildTools.DotNet: - return <DotNet host={host} component={component} token={token} />; + return <DotNet baseUrl={baseUrl} component={component} token={token} />; case BuildTools.CFamily: return languageConfig.os !== undefined ? ( <ClangGCCCustom os={languageConfig.os} baseUrl={baseUrl} - host={host} component={component} isLocal={isLocal} token={token} @@ -69,7 +65,7 @@ export default function AnalysisCommand(props: AnalysisCommandProps) { case BuildTools.Other: return languageConfig.os !== undefined ? ( <Other - host={host} + baseUrl={baseUrl} os={languageConfig.os} component={component} isLocal={isLocal} diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/ClangGCCCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/ClangGCCCommand.tsx index db6ad94b881..510689eb97d 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/ClangGCCCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/ClangGCCCommand.tsx @@ -30,13 +30,12 @@ export interface ClangGCCCustomProps { component: Component; baseUrl: string; isLocal: boolean; - host: string; os: OSs; token: string; } export default function ClangGCCCustom(props: ClangGCCCustomProps) { - const { os, baseUrl, host, component, isLocal, token } = props; + const { os, baseUrl, component, isLocal, token } = props; return ( <div> @@ -45,7 +44,7 @@ export default function ClangGCCCustom(props: ClangGCCCustomProps) { <ExecBuildWrapper os={os} /> <CompilationInfo /> <ExecScanner - host={host} + baseUrl={baseUrl} isLocal={isLocal} component={component} os={os} diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/DotNet.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/DotNet.tsx index e512f38cab2..b8daff7cbef 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/DotNet.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/DotNet.tsx @@ -26,7 +26,7 @@ import DotNetFramework from './DotNetFramework'; export interface DotNetProps { component: Component; - host: string; + baseUrl: string; token: string; } diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/DotNetCore.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/DotNetCore.tsx index c89fb8d9fd5..81b4441a97b 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/DotNetCore.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/DotNetCore.tsx @@ -25,10 +25,10 @@ import { DotNetProps } from './DotNet'; import DotNetExecute from './DotNetExecute'; export default function DotNetCore(props: DotNetProps) { - const { host, component, token } = props; + const { baseUrl, component, token } = props; const commands = [ - `dotnet sonarscanner begin /k:"${component.key}" /d:sonar.host.url="${host}" /d:sonar.login="${token}"`, + `dotnet sonarscanner begin /k:"${component.key}" /d:sonar.host.url="${baseUrl}" /d:sonar.login="${token}"`, 'dotnet build', `dotnet sonarscanner end /d:sonar.login="${token}"` ]; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/DotNetFramework.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/DotNetFramework.tsx index b8846a24cb8..52a94824141 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/DotNetFramework.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/DotNetFramework.tsx @@ -25,10 +25,10 @@ import { DotNetProps } from './DotNet'; import DotNetExecute from './DotNetExecute'; export default function DotNetFramework(props: DotNetProps) { - const { host, component, token } = props; + const { baseUrl, component, token } = props; const commands = [ - `SonarScanner.MSBuild.exe begin /k:"${component.key}" /d:sonar.host.url="${host}" /d:sonar.login="${token}"`, + `SonarScanner.MSBuild.exe begin /k:"${component.key}" /d:sonar.host.url="${baseUrl}" /d:sonar.login="${token}"`, 'MsBuild.exe /t:Rebuild', `SonarScanner.MSBuild.exe end /d:sonar.login="${token}"` ]; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/ExecScanner.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/ExecScanner.tsx index 067af232fd2..646fbd9d1ac 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/ExecScanner.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/ExecScanner.tsx @@ -30,7 +30,7 @@ import DoneNextSteps from '../DoneNextSteps'; export interface ExecScannerProps { component: Component; - host: string; + baseUrl: string; isLocal: boolean; os: OSs; token: string; @@ -38,7 +38,7 @@ export interface ExecScannerProps { } export default function ExecScanner(props: ExecScannerProps) { - const { host, os, isLocal, component, token, cfamily } = props; + const { baseUrl, os, isLocal, component, token, cfamily } = props; const q = quote(os); const command = [ @@ -46,7 +46,7 @@ export default function ExecScanner(props: ExecScannerProps) { '-D' + q(`sonar.projectKey=${component.key}`), '-D' + q('sonar.sources=.'), cfamily ? '-D' + q('sonar.cfamily.build-wrapper-output=bw-output') : undefined, - '-D' + q(`sonar.host.url=${host}`), + '-D' + q(`sonar.host.url=${baseUrl}`), isLocal ? '-D' + q(`sonar.login=${token}`) : undefined ]; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/JavaGradle.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/JavaGradle.tsx index 85a191cf74a..567ee2ccf28 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/JavaGradle.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/JavaGradle.tsx @@ -19,6 +19,7 @@ */ import * as React from 'react'; import { FormattedMessage } from 'react-intl'; +import { GRADLE_SCANNER_VERSION } from '../../../../helpers/constants'; import { translate } from '../../../../helpers/l10n'; import { Component } from '../../../../types/types'; import CodeSnippet from '../../../common/CodeSnippet'; @@ -28,18 +29,20 @@ import DoneNextSteps from '../DoneNextSteps'; export interface JavaGradleProps { component: Component; - host: string; + baseUrl: string; token: string; } export default function JavaGradle(props: JavaGradleProps) { - const { host, component, token } = props; - const config = 'plugins {\n id "org.sonarqube" version "3.4.0.2513"\n}'; + const { baseUrl, component, token } = props; + const config = `plugins { + id "org.sonarqube" version "${GRADLE_SCANNER_VERSION}" +}`; const command = [ './gradlew sonarqube', `-Dsonar.projectKey=${component.key}`, - `-Dsonar.host.url=${host}`, + `-Dsonar.host.url=${baseUrl}`, `-Dsonar.login=${token}` ]; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/JavaMaven.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/JavaMaven.tsx index 473f99d17ac..90e5464eddf 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/JavaMaven.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/JavaMaven.tsx @@ -28,16 +28,16 @@ import DoneNextSteps from '../DoneNextSteps'; export interface JavaMavenProps { component: Component; - host: string; + baseUrl: string; token: string; } export default function JavaMaven(props: JavaMavenProps) { - const { host, component, token } = props; + const { baseUrl, component, token } = props; const command = [ 'mvn clean verify sonar:sonar', `-Dsonar.projectKey=${component.key}`, - `-Dsonar.host.url=${host}`, + `-Dsonar.host.url=${baseUrl}`, `-Dsonar.login=${token}` ]; diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/Other.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/Other.tsx index 2656e640bbf..e1b1358c994 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/Other.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/Other.tsx @@ -26,18 +26,24 @@ import ExecScanner from './ExecScanner'; export interface OtherProps { component: Component; isLocal: boolean; - host: string; + baseUrl: string; os: OSs; token: string; } export default function Other(props: OtherProps) { - const { host, os, component, isLocal, token } = props; + const { baseUrl, os, component, isLocal, token } = props; return ( <div> <DownloadScanner isLocal={isLocal} os={os} token={token} /> - <ExecScanner host={host} isLocal={isLocal} os={os} component={component} token={token} /> + <ExecScanner + baseUrl={baseUrl} + isLocal={isLocal} + os={os} + component={component} + token={token} + /> </div> ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/CLangGCCCommand-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/CLangGCCCommand-test.tsx index b1ecce6b02d..8bbc94e8270 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/CLangGCCCommand-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/CLangGCCCommand-test.tsx @@ -30,7 +30,6 @@ it('should render correctly', () => { os={OSs.Linux} baseUrl="http://example.com" isLocal={true} - host="host" component={mockComponent({ key: 'projectKey' })} token="token" /> diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNet-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNet-test.tsx index 1b40ad0419e..2a7411fdb72 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNet-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNet-test.tsx @@ -24,6 +24,8 @@ import DotNet from '../DotNet'; it('should render correctly', () => { expect( - shallow(<DotNet host="host" component={mockComponent({ key: 'projectKey' })} token="token" />) + shallow( + <DotNet baseUrl="host" component={mockComponent({ key: 'projectKey' })} token="token" /> + ) ).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNetFramework-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNetFramework-test.tsx index 12932520c37..c1dc010779f 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNetFramework-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotNetFramework-test.tsx @@ -25,7 +25,11 @@ import DotNetFramework from '../DotNetFramework'; it('should render correctly', () => { expect( shallow( - <DotNetFramework host="host" component={mockComponent({ key: 'projectKey' })} token="token" /> + <DotNetFramework + baseUrl="host" + component={mockComponent({ key: 'projectKey' })} + token="token" + /> ) ).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotnetCore-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotnetCore-test.tsx index f40ad7f077f..a8998cf65d8 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotnetCore-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/DotnetCore-test.tsx @@ -25,7 +25,7 @@ import DotNetCore from '../DotNetCore'; it('should render correctly', () => { expect( shallow( - <DotNetCore host="host" component={mockComponent({ key: 'projectKey' })} token="token" /> + <DotNetCore baseUrl="host" component={mockComponent({ key: 'projectKey' })} token="token" /> ) ).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/ExecScanner-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/ExecScanner-test.tsx index dbea16d6b08..1fbe02bb25f 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/ExecScanner-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/ExecScanner-test.tsx @@ -38,7 +38,7 @@ it('should render correctly for remote execution', () => { function shallowRender(props: Partial<ExecScannerProps> = {}) { return shallow<ExecScannerProps>( <ExecScanner - host="host" + baseUrl="host" isLocal={true} os={OSs.Linux} component={mockComponent({ key: 'projectKey' })} diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/JavaGradle-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/JavaGradle-test.tsx index 02ced39618e..b556c1f53ac 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/JavaGradle-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/JavaGradle-test.tsx @@ -25,7 +25,7 @@ import JavaGradle from '../JavaGradle'; it('renders correctly', () => { expect( shallow( - <JavaGradle host="host" component={mockComponent({ key: 'projectKey' })} token="token" /> + <JavaGradle baseUrl="host" component={mockComponent({ key: 'projectKey' })} token="token" /> ) ).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/JavaMaven-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/JavaMaven-test.tsx index 808712fe5eb..4eed77c8bea 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/JavaMaven-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/JavaMaven-test.tsx @@ -25,7 +25,7 @@ import JavaMaven from '../JavaMaven'; it('renders correctly', () => { expect( shallow( - <JavaMaven host="host" component={mockComponent({ key: 'projectKey' })} token="token" /> + <JavaMaven baseUrl="host" component={mockComponent({ key: 'projectKey' })} token="token" /> ) ).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/Other-test.tsx b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/Other-test.tsx index 0beb634c1f9..14a43eaf93c 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/Other-test.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/Other-test.tsx @@ -30,7 +30,7 @@ it('renders correctly', () => { function shallowRender(props: Partial<OtherProps> = {}) { return shallow<OtherProps>( <Other - host="host" + baseUrl="host" isLocal={true} os={OSs.Linux} component={mockComponent({ key: 'projectKey' })} diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap index e09a721a914..c7c84eec78d 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/AnalysisCommand-test.tsx.snap @@ -2,6 +2,7 @@ exports[`renders correctly: .NET 1`] = ` <DotNet + baseUrl="http://example.com" component={ Object { "breadcrumbs": Array [], @@ -24,7 +25,6 @@ exports[`renders correctly: .NET 1`] = ` "tags": Array [], } } - host="HOST" token="myToken" /> `; @@ -54,7 +54,6 @@ exports[`renders correctly: CFamily 1`] = ` "tags": Array [], } } - host="HOST" isLocal={true} os="linux" token="myToken" @@ -65,6 +64,7 @@ exports[`renders correctly: Empty CFamily 1`] = `""`; exports[`renders correctly: gradle 1`] = ` <JavaGradle + baseUrl="http://example.com" component={ Object { "breadcrumbs": Array [], @@ -87,13 +87,13 @@ exports[`renders correctly: gradle 1`] = ` "tags": Array [], } } - host="HOST" token="myToken" /> `; exports[`renders correctly: maven 1`] = ` <JavaMaven + baseUrl="http://example.com" component={ Object { "breadcrumbs": Array [], @@ -116,13 +116,13 @@ exports[`renders correctly: maven 1`] = ` "tags": Array [], } } - host="HOST" token="myToken" /> `; exports[`renders correctly: other 1`] = ` <Other + baseUrl="http://example.com" component={ Object { "breadcrumbs": Array [], @@ -145,7 +145,6 @@ exports[`renders correctly: other 1`] = ` "tags": Array [], } } - host="HOST" isLocal={true} os="win" token="myToken" diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/CLangGCCCommand-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/CLangGCCCommand-test.tsx.snap index 02c9c2f09f7..c565c997a5a 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/CLangGCCCommand-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/CLangGCCCommand-test.tsx.snap @@ -17,6 +17,7 @@ exports[`should render correctly 1`] = ` /> <CompilationInfo /> <ExecScanner + baseUrl="http://example.com" cfamily={true} component={ Object { @@ -40,7 +41,6 @@ exports[`should render correctly 1`] = ` "tags": Array [], } } - host="host" isLocal={true} os="linux" token="token" diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DotNet-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DotNet-test.tsx.snap index 02c7e57d294..96e497c5912 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DotNet-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/DotNet-test.tsx.snap @@ -16,6 +16,7 @@ exports[`should render correctly 1`] = ` titleLabelKey="onboarding.build.dotnet.variant" /> <DotNetCore + baseUrl="host" component={ Object { "breadcrumbs": Array [], @@ -38,7 +39,6 @@ exports[`should render correctly 1`] = ` "tags": Array [], } } - host="host" token="token" /> </Fragment> diff --git a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/Other-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/Other-test.tsx.snap index ffbf9f32605..a64504b17ef 100644 --- a/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/Other-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/other/commands/__tests__/__snapshots__/Other-test.tsx.snap @@ -8,6 +8,7 @@ exports[`renders correctly 1`] = ` token="token" /> <ExecScanner + baseUrl="host" component={ Object { "breadcrumbs": Array [], @@ -30,7 +31,6 @@ exports[`renders correctly 1`] = ` "tags": Array [], } } - host="host" isLocal={true} os="linux" token="token" diff --git a/server/sonar-web/src/main/js/components/tutorials/utils.ts b/server/sonar-web/src/main/js/components/tutorials/utils.ts index 7bdc50d230a..19f13e7a09c 100644 --- a/server/sonar-web/src/main/js/components/tutorials/utils.ts +++ b/server/sonar-web/src/main/js/components/tutorials/utils.ts @@ -17,6 +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. */ +import { GRADLE_SCANNER_VERSION } from '../../helpers/constants'; import { convertGithubApiUrlToLink, stripTrailingSlash } from '../../helpers/urls'; import { AlmSettingsInstance, ProjectAlmBindingResponse } from '../../types/alm-settings'; import { UserToken } from '../../types/token'; @@ -27,7 +28,7 @@ export function quote(os: string): (s: string) => string { export function buildGradleSnippet(key: string) { return `plugins { - id "org.sonarqube" version "3.4.0.2513" + id "org.sonarqube" version "${GRADLE_SCANNER_VERSION}" } sonarqube { diff --git a/server/sonar-web/src/main/js/helpers/constants.ts b/server/sonar-web/src/main/js/helpers/constants.ts index 0f73991916f..eb251b676ce 100644 --- a/server/sonar-web/src/main/js/helpers/constants.ts +++ b/server/sonar-web/src/main/js/helpers/constants.ts @@ -76,3 +76,5 @@ export const IMPORT_COMPATIBLE_ALMS = [ export const IMPORT_COMPATIBLE_ALM_COUNT = IMPORT_COMPATIBLE_ALMS.filter( a => a !== AlmKeys.BitbucketCloud ).length; + +export const GRADLE_SCANNER_VERSION = '3.4.0.2513'; |