import { Component } from '../../../types/types';
import { CompilationInfo } from '../components/CompilationInfo';
import CreateYmlFile from '../components/CreateYmlFile';
-import { JreRequiredWarning } from '../components/JreRequiredWarning';
-import { Arch, AutoConfig, BuildTools, TutorialConfig } from '../types';
+import { Arch, BuildTools, TutorialConfig } from '../types';
import { isCFamily } from '../utils';
import { PreambuleYaml } from './PreambuleYaml';
import cFamilyExample from './commands/CFamily';
[BuildTools.Other]: othersExample,
};
-const showJreWarning = (config: TutorialConfig, arch: Arch) => {
- if (!isCFamily(config.buildTool)) {
- return false;
- }
- if (config.autoConfig === AutoConfig.Automatic) {
- return false;
- }
- return arch === Arch.Arm64;
-};
-
export function AnalysisCommand(props: Readonly<AnalysisCommandProps>) {
const { config, arch, mainBranchName, component } = props;
const branchesEnabled = props.hasFeature(Feature.BranchSupport);
return (
<>
<PreambuleYaml buildTool={config.buildTool} component={component} />
- <CreateYmlFile
- yamlFileName="bitbucket-pipelines.yml"
- yamlTemplate={yamlTemplate}
- warning={showJreWarning(config, arch) && <JreRequiredWarning />}
- />
+ <CreateYmlFile yamlFileName="bitbucket-pipelines.yml" yamlTemplate={yamlTemplate} />
{isCFamily(config.buildTool) && <CompilationInfo />}
</>
);
- step: &build-step
name: Build the project, and run the SonarQube analysis
script:
- - export SONAR_SCANNER_VERSION=6.0.0.4432
+ - export SONAR_SCANNER_VERSION=6.1.0.4477
- mkdir $HOME/.sonar
- curl -sSLo $HOME/.sonar/build-wrapper-linux-aarch64.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-aarch64.zip
- unzip -o $HOME/.sonar/build-wrapper-linux-aarch64.zip -d $HOME/.sonar/
- - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}.zip
+ - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}-linux-aarch64.zip
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
- - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}/bin"
+ - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}-linux-aarch64/bin"
- <any step required before running your build, like ./configure>
- $HOME/.sonar/build-wrapper-linux-aarch64/build-wrapper-linux-aarch64 --out-dir bw-output <your clean build command>
- sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json
- step: &build-step
name: Build the project, and run the SonarQube analysis
script:
- - export SONAR_SCANNER_VERSION=6.0.0.4432
+ - export SONAR_SCANNER_VERSION=6.1.0.4477
- mkdir $HOME/.sonar
- curl -sSLo $HOME/.sonar/build-wrapper-linux-aarch64.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-aarch64.zip
- unzip -o $HOME/.sonar/build-wrapper-linux-aarch64.zip -d $HOME/.sonar/
- - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}.zip
+ - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}-linux-aarch64.zip
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
- - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}/bin"
+ - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}-linux-aarch64/bin"
- <any step required before running your build, like ./configure>
- $HOME/.sonar/build-wrapper-linux-aarch64/build-wrapper-linux-aarch64 --out-dir bw-output <your clean build command>
- sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json
- step: &build-step
name: Build the project, and run the SonarQube analysis
script:
- - export SONAR_SCANNER_VERSION=6.0.0.4432
+ - export SONAR_SCANNER_VERSION=6.1.0.4477
- mkdir $HOME/.sonar
- curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip
- unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
- - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}-linux.zip
+ - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}-linux-x64.zip
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
- - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}-linux/bin"
+ - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}-linux-x64/bin"
- <any step required before running your build, like ./configure>
- $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>
- sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json
- step: &build-step
name: Build the project, and run the SonarQube analysis
script:
- - export SONAR_SCANNER_VERSION=6.0.0.4432
+ - export SONAR_SCANNER_VERSION=6.1.0.4477
- mkdir $HOME/.sonar
- curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip
- unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
- - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}-linux.zip
+ - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}-linux-x64.zip
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
- - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}-linux/bin"
+ - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}-linux-x64/bin"
- <any step required before running your build, like ./configure>
- $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output <your clean build command>
- sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2024 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 { LinkStandalone } from '@sonarsource/echoes-react';
-import { FlagMessage } from 'design-system';
-import React from 'react';
-import { FormattedMessage } from 'react-intl';
-import { DocLink } from '../../../helpers/doc-links';
-import { useDocUrl } from '../../../helpers/docs';
-import { translate } from '../../../helpers/l10n';
-
-export function JreRequiredWarning() {
- const scannerRequirementsUrl = useDocUrl(DocLink.SonarScannerRequirements);
-
- return (
- <div>
- <FlagMessage className="sw-mt-2 sw-w-abs-600" variant="warning">
- <p className="sw-mb-2">
- <FormattedMessage
- defaultMessage={translate('onboarding.analysis.sq_scanner.jre_required_warning')}
- id="onboarding.analysis.sq_scanner.jre_required_warning"
- values={{
- link: (
- <LinkStandalone to={scannerRequirementsUrl}>
- {translate('onboarding.analysis.sq_scanner.jre_required_warning.link')}
- </LinkStandalone>
- ),
- }}
- />
- </p>
- </FlagMessage>
- </div>
- );
-}
- name: Install sonar-scanner and build-wrapper
env:
SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}}
- uses: SonarSource/sonarqube-github-c-cpp@v1
+ uses: SonarSource/sonarqube-github-c-cpp@v2
- name: Run build-wrapper
run: |
build-wrapper-linux-aarch64 --out-dir \${{ env.BUILD_WRAPPER_OUT_DIR }} <insert_your_clean_build_command>
- name: Install sonar-scanner and build-wrapper
env:
SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}}
- uses: SonarSource/sonarqube-github-c-cpp@v1
+ uses: SonarSource/sonarqube-github-c-cpp@v2
- name: Run build-wrapper
run: |
build-wrapper-linux-x86-64 --out-dir \${{ env.BUILD_WRAPPER_OUT_DIR }} <insert_your_clean_build_command>
- name: Install sonar-scanner and build-wrapper
env:
SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}}
- uses: SonarSource/sonarqube-github-c-cpp@v1
+ uses: SonarSource/sonarqube-github-c-cpp@v2
- name: Run build-wrapper
run: |
build-wrapper-macosx-x86 --out-dir \${{ env.BUILD_WRAPPER_OUT_DIR }} <insert_your_clean_build_command>
- name: Install sonar-scanner and build-wrapper
env:
SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}}
- uses: SonarSource/sonarqube-github-c-cpp@v1
+ uses: SonarSource/sonarqube-github-c-cpp@v2
- name: Run build-wrapper
run: |
build-wrapper-win-x86-64 --out-dir \${{ env.BUILD_WRAPPER_OUT_DIR }} <insert_your_clean_build_command>
- name: Install sonar-scanner and build-wrapper
env:
SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}}
- uses: SonarSource/sonarqube-github-c-cpp@v1
+ uses: SonarSource/sonarqube-github-c-cpp@v2
- name: Run build-wrapper
run: |
build-wrapper-linux-aarch64 --out-dir \${{ env.BUILD_WRAPPER_OUT_DIR }} <insert_your_clean_build_command>
- name: Install sonar-scanner and build-wrapper
env:
SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}}
- uses: SonarSource/sonarqube-github-c-cpp@v1
+ uses: SonarSource/sonarqube-github-c-cpp@v2
- name: Run build-wrapper
run: |
build-wrapper-linux-x86-64 --out-dir \${{ env.BUILD_WRAPPER_OUT_DIR }} <insert_your_clean_build_command>
- name: Install sonar-scanner and build-wrapper
env:
SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}}
- uses: SonarSource/sonarqube-github-c-cpp@v1
+ uses: SonarSource/sonarqube-github-c-cpp@v2
- name: Run build-wrapper
run: |
build-wrapper-macosx-x86 --out-dir \${{ env.BUILD_WRAPPER_OUT_DIR }} <insert_your_clean_build_command>
- name: Install sonar-scanner and build-wrapper
env:
SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}}
- uses: SonarSource/sonarqube-github-c-cpp@v1
+ uses: SonarSource/sonarqube-github-c-cpp@v2
- name: Run build-wrapper
run: |
build-wrapper-win-x86-64 --out-dir \${{ env.BUILD_WRAPPER_OUT_DIR }} <insert_your_clean_build_command>
- name: Install sonar-scanner and build-wrapper
env:
SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}}
- uses: SonarSource/sonarqube-github-c-cpp@v1
+ uses: SonarSource/sonarqube-github-c-cpp@v2
- name: Run build-wrapper
run: |
${getBuildWrapperExecutableLinux(arch)} --out-dir \${{ env.BUILD_WRAPPER_OUT_DIR }} <insert_your_clean_build_command>
- name: Install sonar-scanner and build-wrapper
env:
SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}}
- uses: SonarSource/sonarqube-github-c-cpp@v1
+ uses: SonarSource/sonarqube-github-c-cpp@v2
- name: Run build-wrapper
run: |
build-wrapper-macosx-x86 --out-dir \${{ env.BUILD_WRAPPER_OUT_DIR }} <insert_your_clean_build_command>
- name: Install sonar-scanner and build-wrapper
env:
SONAR_HOST_URL: \${{secrets.SONAR_HOST_URL}}
- uses: SonarSource/sonarqube-github-c-cpp@v1
+ uses: SonarSource/sonarqube-github-c-cpp@v2
- name: Run build-wrapper
run: |
build-wrapper-win-x86-64 --out-dir \${{ env.BUILD_WRAPPER_OUT_DIR }} <insert_your_clean_build_command>
import GithubCFamilyExampleRepositories from '../components/GithubCFamilyExampleRepositories';
import GradleBuildSelection from '../components/GradleBuildSelection';
import { InlineSnippet } from '../components/InlineSnippet';
-import { JreRequiredWarning } from '../components/JreRequiredWarning';
import RenderOptions from '../components/RenderOptions';
import { Arch, BuildTools, GradleBuildDSL, OSs, TutorialConfig, TutorialModes } from '../types';
-import {
- shouldShowArchSelector,
- shouldShowGithubCFamilyExampleRepositories,
- showJreWarning,
-} from '../utils';
+import { shouldShowArchSelector, shouldShowGithubCFamilyExampleRepositories } from '../utils';
import PipeCommand from './commands/PipeCommand';
export interface YmlFileStepProps extends WithAvailableFeaturesProps {
export function YmlFileStep(props: Readonly<YmlFileStepProps>) {
const { component, hasCLanguageFeature, setDone } = props;
- const [os, setOs] = React.useState<OSs>(OSs.Linux);
const [arch, setArch] = React.useState<Arch>(Arch.X86_64);
const [config, setConfig] = React.useState<TutorialConfig>({});
supportCFamily={hasCLanguageFeature}
onSetConfig={onSetConfig}
/>
- {(config.buildTool === BuildTools.Other ||
- config.buildTool === BuildTools.Cpp ||
- config.buildTool === BuildTools.ObjectiveC) && (
- <RenderOptions
- label={translate('onboarding.build.other.os')}
- checked={os}
- onCheck={(value: OSs) => setOs(value)}
- optionLabelKey="onboarding.build.other.os"
- options={[OSs.Linux, OSs.Windows, OSs.MacOS]}
- titleLabelKey="onboarding.build.other.os"
- />
- )}
- {shouldShowArchSelector(os, config) && (
+ {shouldShowArchSelector(OSs.Linux, config) && (
<RenderOptions
label={translate('onboarding.build.other.architecture')}
checked={arch}
),
}}
/>
- {showJreWarning(config, arch) && <JreRequiredWarning />}
<PipeCommand
buildTool={buildTool}
projectKey={component.key}
- os={os}
- arch={arch}
+ arch={shouldShowArchSelector(OSs.Linux, config) ? arch : Arch.X86_64}
config={config}
/>
// C++/Objective-C
await user.click(ui.cppBuildButton.get());
- //linux
expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot('CPP: sonar-project.properties');
expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot('CPP: gitlab-ci.yml');
- //windows
- await user.click(ui.windowsButton.get());
- expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot('CPP - windows: gitlab-ci.yml');
- //macos
- await user.click(ui.macosButton.get());
- expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot('CPP - macos: gitlab-ci.yml');
// c++ manual config
await user.click(ui.autoConfigManual.get());
-
- //linux
- await user.click(ui.linuxButton.get());
expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot('CPP - manual: gitlab-ci.yml');
- //windows
- await user.click(ui.windowsButton.get());
- expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot('CPP - windows: gitlab-ci.yml');
- //macos
- await user.click(ui.macosButton.get());
- expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot('CPP - macos: gitlab-ci.yml');
-
// Other
await user.click(ui.otherBuildButton.get());
expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot('Other: sonar-project.properties');
sonarqube-check:
stage: sonarqube-check
- dependencies:
- - get-binaries
- - build
- cache:
- policy: pull
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
-
-
+
script:
- "apt-get update"
- "apt-get install --yes --no-install-recommends openjdk-17-jre"
"
`;
-exports[`should follow and complete all steps: CPP - macos: gitlab-ci.yml 1`] = `
-"image: gcc
-
-variables:
- SONAR_USER_HOME: "\${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
- GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
-
-
-stages:
- - get-binaries
- - build
- - sonarqube-check
- - sonarqube-vulnerability-report
-
-get-binaries:
- stage: get-binaries
- cache:
- policy: push
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
-
- script:
- # Download sonar-scanner
- - curl -sSLo ./sonar-scanner.zip 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.0.0.4432-macosx.zip'
- - unzip -o sonar-scanner.zip
- - mv sonar-scanner-6.0.0.4432-macosx sonar-scanner
-
-
- rules:
- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- - if: $CI_COMMIT_BRANCH == 'master'
- - if: $CI_COMMIT_BRANCH == 'main'
- - if: $CI_COMMIT_BRANCH == 'develop'
-
-build:
- stage: build
- script:
- # prepare the build tree
- - mkdir build
-
- cache:
- policy: pull-push
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
-
-
-sonarqube-check:
- stage: sonarqube-check
- dependencies:
- - get-binaries
- - build
- cache:
- policy: pull
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
-
-
- script: sonar-scanner/bin/sonar-scanner --define sonar.host.url="\${SONAR_HOST_URL}"
- allow_failure: true
- rules:
- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- - if: $CI_COMMIT_BRANCH == 'master'
- - if: $CI_COMMIT_BRANCH == 'main'
- - if: $CI_COMMIT_BRANCH == 'develop'
-
-sonarqube-vulnerability-report:
- stage: sonarqube-vulnerability-report
- script:
- - 'curl -u "\${SONAR_TOKEN}:" "\${SONAR_HOST_URL}/api/issues/gitlab_sast_export?projectKey=my-project&branch=\${CI_COMMIT_BRANCH}&pullRequest=\${CI_MERGE_REQUEST_IID}" -o gl-sast-sonar-report.json'
- allow_failure: true
- rules:
- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- - if: $CI_COMMIT_BRANCH == 'master'
- - if: $CI_COMMIT_BRANCH == 'main'
- - if: $CI_COMMIT_BRANCH == 'develop'
- artifacts:
- expire_in: 1 day
- reports:
- sast: gl-sast-sonar-report.json
-"
-`;
-
-exports[`should follow and complete all steps: CPP - macos: gitlab-ci.yml 2`] = `
-"image: gcc
-
-variables:
- SONAR_USER_HOME: "\${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
- GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
- BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
-
-stages:
- - get-binaries
- - build
- - sonarqube-check
- - sonarqube-vulnerability-report
-
-get-binaries:
- stage: get-binaries
- cache:
- policy: push
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
- - build-wrapper/
- script:
- # Download sonar-scanner
- - curl -sSLo ./sonar-scanner.zip 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.0.0.4432-macosx.zip'
- - unzip -o sonar-scanner.zip
- - mv sonar-scanner-6.0.0.4432-macosx sonar-scanner
- # Download build-wrapper
- - curl -sSLo ./build-wrapper-macosx-x86.zip "$SONAR_HOST_URL/static/cpp/build-wrapper-macosx-x86.zip"
- - unzip -o build-wrapper-macosx-x86.zip
- - mv build-wrapper-macosx-x86 build-wrapper
-
- rules:
- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- - if: $CI_COMMIT_BRANCH == 'master'
- - if: $CI_COMMIT_BRANCH == 'main'
- - if: $CI_COMMIT_BRANCH == 'develop'
-
-build:
- stage: build
- script:
- # prepare the build tree
- - mkdir build
- - build-wrapper/build-wrapper-macosx-x86 --out-dir "\${BUILD_WRAPPER_OUT_DIR}" <your clean build command>
- cache:
- policy: pull-push
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
- - build-wrapper/
- - "\${BUILD_WRAPPER_OUT_DIR}"
-
-sonarqube-check:
- stage: sonarqube-check
- dependencies:
- - get-binaries
- - build
- cache:
- policy: pull
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
- - "\${BUILD_WRAPPER_OUT_DIR}"
-
- script: sonar-scanner/bin/sonar-scanner --define sonar.host.url="\${SONAR_HOST_URL}"
- allow_failure: true
- rules:
- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- - if: $CI_COMMIT_BRANCH == 'master'
- - if: $CI_COMMIT_BRANCH == 'main'
- - if: $CI_COMMIT_BRANCH == 'develop'
-
-sonarqube-vulnerability-report:
- stage: sonarqube-vulnerability-report
- script:
- - 'curl -u "\${SONAR_TOKEN}:" "\${SONAR_HOST_URL}/api/issues/gitlab_sast_export?projectKey=my-project&branch=\${CI_COMMIT_BRANCH}&pullRequest=\${CI_MERGE_REQUEST_IID}" -o gl-sast-sonar-report.json'
- allow_failure: true
- rules:
- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- - if: $CI_COMMIT_BRANCH == 'master'
- - if: $CI_COMMIT_BRANCH == 'main'
- - if: $CI_COMMIT_BRANCH == 'develop'
- artifacts:
- expire_in: 1 day
- reports:
- sast: gl-sast-sonar-report.json
-"
-`;
-
exports[`should follow and complete all steps: CPP - manual: gitlab-ci.yml 1`] = `
"image: gcc
stages:
- get-binaries
- - build
- - sonarqube-check
+ - build-analyze
- sonarqube-vulnerability-report
get-binaries:
- build-wrapper/
script:
# Download sonar-scanner
- - curl -sSLo ./sonar-scanner.zip 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.0.0.4432-linux.zip'
+ - curl -sSLo ./sonar-scanner.zip 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.1.0.4477-linux-x64.zip'
- unzip -o sonar-scanner.zip
- - mv sonar-scanner-6.0.0.4432-linux sonar-scanner
+ - mv sonar-scanner-6.1.0.4477-linux-x64 sonar-scanner
# Download build-wrapper
- curl -sSLo ./build-wrapper-linux-x86.zip "$SONAR_HOST_URL/static/cpp/build-wrapper-linux-x86.zip"
- unzip -o build-wrapper-linux-x86.zip
- mv build-wrapper-linux-x86 build-wrapper
-
- rules:
- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- - if: $CI_COMMIT_BRANCH == 'master'
- - if: $CI_COMMIT_BRANCH == 'main'
- - if: $CI_COMMIT_BRANCH == 'develop'
-
-build:
- stage: build
- script:
- # prepare the build tree
- - mkdir build
- - build-wrapper/build-wrapper-linux-x86-64 --out-dir "\${BUILD_WRAPPER_OUT_DIR}" <your clean build command>
- cache:
- policy: pull-push
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
- - build-wrapper/
- - "\${BUILD_WRAPPER_OUT_DIR}"
-sonarqube-check:
- stage: sonarqube-check
- dependencies:
- - get-binaries
- - build
- cache:
- policy: pull
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
- - "\${BUILD_WRAPPER_OUT_DIR}"
-
- script: sonar-scanner/bin/sonar-scanner --define sonar.host.url="\${SONAR_HOST_URL}"
- allow_failure: true
- rules:
- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- - if: $CI_COMMIT_BRANCH == 'master'
- - if: $CI_COMMIT_BRANCH == 'main'
- - if: $CI_COMMIT_BRANCH == 'develop'
-
-sonarqube-vulnerability-report:
- stage: sonarqube-vulnerability-report
- script:
- - 'curl -u "\${SONAR_TOKEN}:" "\${SONAR_HOST_URL}/api/issues/gitlab_sast_export?projectKey=my-project&branch=\${CI_COMMIT_BRANCH}&pullRequest=\${CI_MERGE_REQUEST_IID}" -o gl-sast-sonar-report.json'
- allow_failure: true
- rules:
- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- - if: $CI_COMMIT_BRANCH == 'master'
- - if: $CI_COMMIT_BRANCH == 'main'
- - if: $CI_COMMIT_BRANCH == 'develop'
- artifacts:
- expire_in: 1 day
- reports:
- sast: gl-sast-sonar-report.json
-"
-`;
-
-exports[`should follow and complete all steps: CPP - windows: gitlab-ci.yml 1`] = `
-"image: gcc
-
-variables:
- SONAR_USER_HOME: "\${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
- GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
-
-
-stages:
- - get-binaries
- - build
- - sonarqube-check
- - sonarqube-vulnerability-report
-
-get-binaries:
- stage: get-binaries
- cache:
- policy: push
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
-
- script:
- # Download sonar-scanner
- - curl -sSLo ./sonar-scanner.zip 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.0.0.4432-windows.zip'
- - unzip -o sonar-scanner.zip
- - mv sonar-scanner-6.0.0.4432-windows sonar-scanner
-
-
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH == 'master'
- if: $CI_COMMIT_BRANCH == 'develop'
build:
- stage: build
+ stage: build-analyze
script:
- # prepare the build tree
- - mkdir build
-
- cache:
- policy: pull-push
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
-
-
-sonarqube-check:
- stage: sonarqube-check
- dependencies:
- - get-binaries
- - build
+ - build-wrapper/build-wrapper-linux-x86-64 --out-dir "\${BUILD_WRAPPER_OUT_DIR}" <your clean build command>
+ - sonar-scanner/bin/sonar-scanner --define sonar.host.url="\${SONAR_HOST_URL}" --define sonar.cfamily.compile-commands="\${BUILD_WRAPPER_OUT_DIR}/compile_commands.json"
cache:
policy: pull
key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
-
-
- script: sonar-scanner/bin/sonar-scanner --define sonar.host.url="\${SONAR_HOST_URL}"
- allow_failure: true
- rules:
- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- - if: $CI_COMMIT_BRANCH == 'master'
- - if: $CI_COMMIT_BRANCH == 'main'
- - if: $CI_COMMIT_BRANCH == 'develop'
-
-sonarqube-vulnerability-report:
- stage: sonarqube-vulnerability-report
- script:
- - 'curl -u "\${SONAR_TOKEN}:" "\${SONAR_HOST_URL}/api/issues/gitlab_sast_export?projectKey=my-project&branch=\${CI_COMMIT_BRANCH}&pullRequest=\${CI_MERGE_REQUEST_IID}" -o gl-sast-sonar-report.json'
- allow_failure: true
- rules:
- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- - if: $CI_COMMIT_BRANCH == 'master'
- - if: $CI_COMMIT_BRANCH == 'main'
- - if: $CI_COMMIT_BRANCH == 'develop'
- artifacts:
- expire_in: 1 day
- reports:
- sast: gl-sast-sonar-report.json
-"
-`;
-
-exports[`should follow and complete all steps: CPP - windows: gitlab-ci.yml 2`] = `
-"image: gcc
-
-variables:
- SONAR_USER_HOME: "\${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
- GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
- BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
-
-stages:
- - get-binaries
- - build
- - sonarqube-check
- - sonarqube-vulnerability-report
-
-get-binaries:
- stage: get-binaries
- cache:
- policy: push
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
- - build-wrapper/
- script:
- # Download sonar-scanner
- - curl -sSLo ./sonar-scanner.zip 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.0.0.4432-windows.zip'
- - unzip -o sonar-scanner.zip
- - mv sonar-scanner-6.0.0.4432-windows sonar-scanner
- # Download build-wrapper
- - curl -sSLo ./build-wrapper-win-x86.zip "$SONAR_HOST_URL/static/cpp/build-wrapper-win-x86.zip"
- - unzip -o build-wrapper-win-x86.zip
- - mv build-wrapper-win-x86 build-wrapper
-
- rules:
- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- - if: $CI_COMMIT_BRANCH == 'master'
- - if: $CI_COMMIT_BRANCH == 'main'
- - if: $CI_COMMIT_BRANCH == 'develop'
-
-build:
- stage: build
- script:
- # prepare the build tree
- - mkdir build
- - build-wrapper/build-wrapper-win-x86-64.exe --out-dir "\${BUILD_WRAPPER_OUT_DIR}" <your clean build command>
- cache:
- policy: pull-push
- key: "\${CI_COMMIT_SHORT_SHA}"
paths:
- sonar-scanner/
- build-wrapper/
- - "\${BUILD_WRAPPER_OUT_DIR}"
-
-sonarqube-check:
- stage: sonarqube-check
- dependencies:
- - get-binaries
- - build
- cache:
- policy: pull
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
- - "\${BUILD_WRAPPER_OUT_DIR}"
-
- script: sonar-scanner/bin/sonar-scanner --define sonar.host.url="\${SONAR_HOST_URL}"
- allow_failure: true
- rules:
- - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- - if: $CI_COMMIT_BRANCH == 'master'
- - if: $CI_COMMIT_BRANCH == 'main'
- - if: $CI_COMMIT_BRANCH == 'develop'
sonarqube-vulnerability-report:
stage: sonarqube-vulnerability-report
stages:
- get-binaries
- - build
- sonarqube-check
- sonarqube-vulnerability-report
script:
# Download sonar-scanner
- - curl -sSLo ./sonar-scanner.zip 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.0.0.4432-linux.zip'
+ - curl -sSLo ./sonar-scanner.zip 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.1.0.4477-linux-x64.zip'
- unzip -o sonar-scanner.zip
- - mv sonar-scanner-6.0.0.4432-linux sonar-scanner
+ - mv sonar-scanner-6.1.0.4477-linux-x64 sonar-scanner
-
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH == 'master'
- if: $CI_COMMIT_BRANCH == 'main'
- if: $CI_COMMIT_BRANCH == 'develop'
-build:
- stage: build
- script:
- # prepare the build tree
- - mkdir build
-
- cache:
- policy: pull-push
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
-
-
sonarqube-check:
stage: sonarqube-check
dependencies:
- get-binaries
- - build
cache:
policy: pull
key: "\${CI_COMMIT_SHORT_SHA}"
paths:
- sonar-scanner/
-
-
+
script: sonar-scanner/bin/sonar-scanner --define sonar.host.url="\${SONAR_HOST_URL}"
allow_failure: true
rules:
sonarqube-check:
stage: sonarqube-check
- dependencies:
- - get-binaries
- - build
- cache:
- policy: pull
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
-
-
+
script: gradle sonar
allow_failure: true
rules:
sonarqube-check:
stage: sonarqube-check
- dependencies:
- - get-binaries
- - build
- cache:
- policy: pull
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
-
-
+
script:
- mvn verify sonar:sonar
allow_failure: true
sonarqube-check:
stage: sonarqube-check
- dependencies:
- - get-binaries
- - build
- cache:
- policy: pull
- key: "\${CI_COMMIT_SHORT_SHA}"
- paths:
- - sonar-scanner/
-
-
+
script:
- - sonar-scanner
+ - sonar-scanner --define sonar.host.url="\${SONAR_HOST_URL}"
allow_failure: true
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
import { Arch, AutoConfig, BuildTools, OSs, TutorialConfig } from '../../types';
import {
SONAR_SCANNER_CLI_LATEST_VERSION,
- getBuildWrapperExecutable,
- getBuildWrapperFolder,
+ getBuildWrapperExecutableLinux,
+ getBuildWrapperFolderLinux,
getScannerUrlSuffix,
isCFamily,
+ shouldFetchBuildWrapper,
} from '../../utils';
export interface PipeCommandProps {
arch: Arch;
buildTool: BuildTools;
config: TutorialConfig;
- os: OSs;
projectKey: string;
}
},
[BuildTools.Cpp]: {
image: 'gcc',
- script: (autoConfig?: AutoConfig) =>
- `sonar-scanner/bin/sonar-scanner --define sonar.host.url="\${SONAR_HOST_URL}" ${autoConfig === AutoConfig.Manual ? `--define sonar.cfamily.compile-commands="\${BUILD_WRAPPER_OUT_DIR}/compile_commands.json"` : ''}`,
+ script: (_, autoConfig?: AutoConfig) =>
+ `sonar-scanner/bin/sonar-scanner --define sonar.host.url="\${SONAR_HOST_URL}" ` +
+ (autoConfig === AutoConfig.Manual
+ ? `--define sonar.cfamily.compile-commands="\${BUILD_WRAPPER_OUT_DIR}/compile_commands.json"`
+ : ''),
},
[BuildTools.ObjectiveC]: {
image: 'gcc',
- script: (autoConfig?: AutoConfig) =>
- `sonar-scanner/bin/sonar-scanner --define sonar.host.url="\${SONAR_HOST_URL}" ${autoConfig === AutoConfig.Manual ? `--define sonar.cfamily.compile-commands="\${BUILD_WRAPPER_OUT_DIR}/compile_commands.json"` : ''}`,
+ script: (_) =>
+ `sonar-scanner/bin/sonar-scanner --define sonar.host.url="\${SONAR_HOST_URL}" ` +
+ `--define sonar.cfamily.compile-commands="\${BUILD_WRAPPER_OUT_DIR}/compile_commands.json"`,
},
[BuildTools.Other]: {
image: `
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]`,
script: () => `
- - sonar-scanner`,
+ - sonar-scanner --define sonar.host.url="\${SONAR_HOST_URL}"`,
},
};
export default function PipeCommand(props: Readonly<PipeCommandProps>) {
- const { projectKey, buildTool, config, os, arch } = props;
+ const { projectKey, buildTool, config, arch } = props;
const { autoConfig } = config;
const { image, script } = BUILD_TOOL_SPECIFIC[buildTool];
- const suffix = getScannerUrlSuffix(os, arch);
+ const suffix = getScannerUrlSuffix(OSs.Linux, arch);
+ const buildWrapperFolder = getBuildWrapperFolderLinux(arch);
const getBinaries = `get-binaries:
stage: get-binaries
key: "\${CI_COMMIT_SHORT_SHA}"
paths:
- sonar-scanner/
- ${autoConfig === AutoConfig.Manual ? `- build-wrapper/` : ''}
+ ${shouldFetchBuildWrapper(buildTool, autoConfig) ? `- build-wrapper/` : ''}
script:
# Download sonar-scanner
- curl -sSLo ./sonar-scanner.zip 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_CLI_LATEST_VERSION}${suffix}.zip'
- unzip -o sonar-scanner.zip
- mv sonar-scanner-${SONAR_SCANNER_CLI_LATEST_VERSION}${suffix} sonar-scanner
${
- autoConfig === AutoConfig.Manual
+ shouldFetchBuildWrapper(buildTool, autoConfig)
? `# Download build-wrapper
- - curl -sSLo ./${getBuildWrapperFolder(os, arch)}.zip "$SONAR_HOST_URL/static/cpp/${getBuildWrapperFolder(os, arch)}.zip"
- - unzip -o ${getBuildWrapperFolder(os, arch)}.zip
- - mv ${getBuildWrapperFolder(os, arch)} build-wrapper`
+ - curl -sSLo ./${buildWrapperFolder}.zip "$SONAR_HOST_URL/static/cpp/${buildWrapperFolder}.zip"
+ - unzip -o ${buildWrapperFolder}.zip
+ - mv ${buildWrapperFolder} build-wrapper
+`
: ''
}
-
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_BRANCH == 'master'
- if: $CI_COMMIT_BRANCH == 'main'
- if: $CI_COMMIT_BRANCH == 'develop'`;
- const build = `build:
- stage: build
+ const buildAnalyze = `build:
+ stage: build-analyze
script:
- # prepare the build tree
- - mkdir build
- ${
- autoConfig === AutoConfig.Manual
- ? `- build-wrapper/${getBuildWrapperExecutable(os, arch)} --out-dir "\${BUILD_WRAPPER_OUT_DIR}" <your clean build command>`
- : ''
- }
+ - build-wrapper/${getBuildWrapperExecutableLinux(arch)} --out-dir "\${BUILD_WRAPPER_OUT_DIR}" <your clean build command>
+ - ${script(projectKey, autoConfig)}
cache:
- policy: pull-push
+ policy: pull
key: "\${CI_COMMIT_SHORT_SHA}"
paths:
- sonar-scanner/
- ${
- autoConfig === AutoConfig.Manual
- ? `- build-wrapper/
- - "\${BUILD_WRAPPER_OUT_DIR}"`
- : ''
- }`;
+ - build-wrapper/`;
const sonarqubeCheck = `sonarqube-check:
stage: sonarqube-check
- dependencies:
+ ${
+ isCFamily(buildTool)
+ ? `dependencies:
- get-binaries
- - build
cache:
policy: pull
key: "\${CI_COMMIT_SHORT_SHA}"
paths:
- sonar-scanner/
- ${autoConfig === AutoConfig.Manual ? `- "\${BUILD_WRAPPER_OUT_DIR}"` : ''}
-
+`
+ : ''
+ }
script: ${script(projectKey, autoConfig)}
allow_failure: true
rules:
sast: gl-sast-sonar-report.json
`;
- let stageDeclaration = ['sonarqube-check', 'sonarqube-vulnerability-report'];
- let stages = [sonarqubeCheck, vulnerabilityReport];
+ let stageDeclaration = ['sonarqube-vulnerability-report'];
+ let stages = [vulnerabilityReport];
- if (buildTool === BuildTools.Cpp || buildTool === BuildTools.ObjectiveC) {
+ if (shouldFetchBuildWrapper(buildTool, autoConfig)) {
// only for c-family languages on manual configuration
- stages = [getBinaries, build, ...stages];
- stageDeclaration = ['get-binaries', 'build', ...stageDeclaration];
+ stages = [buildAnalyze, ...stages];
+ stageDeclaration = ['build-analyze', ...stageDeclaration];
+ } else {
+ stages = [sonarqubeCheck, ...stages];
+ stageDeclaration = ['sonarqube-check', ...stageDeclaration];
+ }
+
+ if (isCFamily(buildTool)) {
+ stages = [getBinaries, ...stages];
+ stageDeclaration = ['get-binaries', ...stageDeclaration];
}
const stageDefinition =
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`can choose build tools and copy provided settings: c++ (automatic) and other linux arm64: download scanner 1`] = `
-"export SONAR_SCANNER_VERSION=6.0.0.4432
-export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION
-curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION.zip
+"export SONAR_SCANNER_VERSION=6.1.0.4477
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux-aarch64
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux-aarch64.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
`;
exports[`can choose build tools and copy provided settings: c++ (automatic) and other linux: download scanner 1`] = `
-"export SONAR_SCANNER_VERSION=6.0.0.4432
-export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
-curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
+"export SONAR_SCANNER_VERSION=6.1.0.4477
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux-x64
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux-x64.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
`;
exports[`can choose build tools and copy provided settings: c++ (automatic) and other linux: execute scanner 2`] = `
-"export SONAR_SCANNER_VERSION=6.0.0.4432
-export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
-curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
+"export SONAR_SCANNER_VERSION=6.1.0.4477
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux-x64
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux-x64.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
`;
exports[`can choose build tools and copy provided settings: c++ (automatic) and other macos: execute scanner 2`] = `
-"export SONAR_SCANNER_VERSION=6.0.0.4432
-export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-macosx
-curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-macosx.zip
+"export SONAR_SCANNER_VERSION=6.1.0.4477
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-macosx-x64
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-macosx-x64.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
exports[`can choose build tools and copy provided settings: c++ (automatic) and other windows: execute scanner 1`] = `"sonar-scanner.bat -D"sonar.projectKey=my-project" -D"sonar.sources=." -D"sonar.host.url=http://localhost:9000""`;
exports[`can choose build tools and copy provided settings: c++ (automatic) and other windows: execute scanner 2`] = `
-"$env:SONAR_SCANNER_VERSION = "6.0.0.4432"
+"$env:SONAR_SCANNER_VERSION = "6.1.0.4477"
$env:SONAR_DIRECTORY = [System.IO.Path]::Combine($(get-location).Path,".sonar")
-$env:SONAR_SCANNER_HOME = "$env:SONAR_DIRECTORY/sonar-scanner-$env:SONAR_SCANNER_VERSION-windows"
+$env:SONAR_SCANNER_HOME = "$env:SONAR_DIRECTORY/sonar-scanner-$env:SONAR_SCANNER_VERSION-windows-x64"
rm $env:SONAR_SCANNER_HOME -Force -Recurse -ErrorAction SilentlyContinue
New-Item -path $env:SONAR_SCANNER_HOME -type directory
-(New-Object System.Net.WebClient).DownloadFile("https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$env:SONAR_SCANNER_VERSION-windows.zip", "$env:SONAR_DIRECTORY/sonar-scanner.zip")
+(New-Object System.Net.WebClient).DownloadFile("https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$env:SONAR_SCANNER_VERSION-windows-x64.zip", "$env:SONAR_DIRECTORY/sonar-scanner.zip")
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory("$env:SONAR_DIRECTORY/sonar-scanner.zip", "$env:SONAR_DIRECTORY")
rm ./.sonar/sonar-scanner.zip -Force -ErrorAction SilentlyContinue
`;
exports[`can choose build tools and copy provided settings: c++ (manual) linux arm64: download scanner 1`] = `
-"export SONAR_SCANNER_VERSION=6.0.0.4432
-export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION
-curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION.zip
+"export SONAR_SCANNER_VERSION=6.1.0.4477
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux-aarch64
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux-aarch64.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
`;
exports[`can choose build tools and copy provided settings: c++ (manual) linux: download scanner 1`] = `
-"export SONAR_SCANNER_VERSION=6.0.0.4432
-export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
-curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
+"export SONAR_SCANNER_VERSION=6.1.0.4477
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux-x64
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux-x64.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
`;
exports[`can choose build tools and copy provided settings: c++ (manual) macos: download scanner 1`] = `
-"export SONAR_SCANNER_VERSION=6.0.0.4432
-export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-macosx
-curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-macosx.zip
+"export SONAR_SCANNER_VERSION=6.1.0.4477
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-macosx-x64
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-macosx-x64.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
`;
exports[`can choose build tools and copy provided settings: c++ (manual) windows: download scanner 1`] = `
-"$env:SONAR_SCANNER_VERSION = "6.0.0.4432"
+"$env:SONAR_SCANNER_VERSION = "6.1.0.4477"
$env:SONAR_DIRECTORY = [System.IO.Path]::Combine($(get-location).Path,".sonar")
-$env:SONAR_SCANNER_HOME = "$env:SONAR_DIRECTORY/sonar-scanner-$env:SONAR_SCANNER_VERSION-windows"
+$env:SONAR_SCANNER_HOME = "$env:SONAR_DIRECTORY/sonar-scanner-$env:SONAR_SCANNER_VERSION-windows-x64"
rm $env:SONAR_SCANNER_HOME -Force -Recurse -ErrorAction SilentlyContinue
New-Item -path $env:SONAR_SCANNER_HOME -type directory
-(New-Object System.Net.WebClient).DownloadFile("https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$env:SONAR_SCANNER_VERSION-windows.zip", "$env:SONAR_DIRECTORY/sonar-scanner.zip")
+(New-Object System.Net.WebClient).DownloadFile("https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$env:SONAR_SCANNER_VERSION-windows-x64.zip", "$env:SONAR_DIRECTORY/sonar-scanner.zip")
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory("$env:SONAR_DIRECTORY/sonar-scanner.zip", "$env:SONAR_DIRECTORY")
rm ./.sonar/sonar-scanner.zip -Force -ErrorAction SilentlyContinue
`;
exports[`can choose build tools and copy provided settings: objective-c linux arm64: download scanner 1`] = `
-"export SONAR_SCANNER_VERSION=6.0.0.4432
-export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION
-curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION.zip
+"export SONAR_SCANNER_VERSION=6.1.0.4477
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux-aarch64
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux-aarch64.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
`;
exports[`can choose build tools and copy provided settings: objective-c linux: download scanner 1`] = `
-"export SONAR_SCANNER_VERSION=6.0.0.4432
-export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
-curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
+"export SONAR_SCANNER_VERSION=6.1.0.4477
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux-x64
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux-x64.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
`;
exports[`can choose build tools and copy provided settings: objective-c macos: download scanner 1`] = `
-"export SONAR_SCANNER_VERSION=6.0.0.4432
-export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-macosx
-curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-macosx.zip
+"export SONAR_SCANNER_VERSION=6.1.0.4477
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-macosx-x64
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-macosx-x64.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
`;
exports[`can choose build tools and copy provided settings: objective-c windows: download scanner 1`] = `
-"$env:SONAR_SCANNER_VERSION = "6.0.0.4432"
+"$env:SONAR_SCANNER_VERSION = "6.1.0.4477"
$env:SONAR_DIRECTORY = [System.IO.Path]::Combine($(get-location).Path,".sonar")
-$env:SONAR_SCANNER_HOME = "$env:SONAR_DIRECTORY/sonar-scanner-$env:SONAR_SCANNER_VERSION-windows"
+$env:SONAR_SCANNER_HOME = "$env:SONAR_DIRECTORY/sonar-scanner-$env:SONAR_SCANNER_VERSION-windows-x64"
rm $env:SONAR_SCANNER_HOME -Force -Recurse -ErrorAction SilentlyContinue
New-Item -path $env:SONAR_SCANNER_HOME -type directory
-(New-Object System.Net.WebClient).DownloadFile("https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$env:SONAR_SCANNER_VERSION-windows.zip", "$env:SONAR_DIRECTORY/sonar-scanner.zip")
+(New-Object System.Net.WebClient).DownloadFile("https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$env:SONAR_SCANNER_VERSION-windows-x64.zip", "$env:SONAR_DIRECTORY/sonar-scanner.zip")
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory("$env:SONAR_DIRECTORY/sonar-scanner.zip", "$env:SONAR_DIRECTORY")
rm ./.sonar/sonar-scanner.zip -Force -ErrorAction SilentlyContinue
import {
ClipboardIconButton,
CodeSnippet,
- FlagMessage,
NumberedList,
NumberedListItem,
SubHeading,
const { arch, os, isLocal, token } = props;
const docUrl = useDocUrl(DocLink.SonarScanner);
- const scannerRequirementsUrl = useDocUrl(DocLink.SonarScannerRequirements);
return (
<div className="sw-mb-4">
</p>
) : (
<>
- {os === OSs.Linux && arch === Arch.Arm64 && (
- <FlagMessage className="sw-mt-2 sw-w-abs-600" variant="warning">
- <p className="sw-mb-2">
- <FormattedMessage
- defaultMessage={translate('onboarding.analysis.sq_scanner.jre_required_warning')}
- id="onboarding.analysis.sq_scanner.jre_required_warning"
- values={{
- link: (
- <Link to={scannerRequirementsUrl}>
- {translate('onboarding.analysis.sq_scanner.jre_required_warning.link')}
- </Link>
- ),
- }}
- />
- </p>
- </FlagMessage>
- )}
<CodeSnippet
className="sw-p-4"
wrap
}
function getRemoteDownloadSnippet(os: OSs, arch: Arch) {
+ const suffix = getScannerUrlSuffix(os, arch);
if (os === OSs.Windows) {
return `$env:SONAR_SCANNER_VERSION = "${SONAR_SCANNER_CLI_LATEST_VERSION}"
$env:SONAR_DIRECTORY = [System.IO.Path]::Combine($(get-location).Path,".sonar")
-$env:SONAR_SCANNER_HOME = "$env:SONAR_DIRECTORY/sonar-scanner-$env:SONAR_SCANNER_VERSION-windows"
+$env:SONAR_SCANNER_HOME = "$env:SONAR_DIRECTORY/sonar-scanner-$env:SONAR_SCANNER_VERSION${suffix}"
rm $env:SONAR_SCANNER_HOME -Force -Recurse -ErrorAction SilentlyContinue
New-Item -path $env:SONAR_SCANNER_HOME -type directory
-(New-Object System.Net.WebClient).DownloadFile("https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$env:SONAR_SCANNER_VERSION-windows.zip", "$env:SONAR_DIRECTORY/sonar-scanner.zip")
+(New-Object System.Net.WebClient).DownloadFile("https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$env:SONAR_SCANNER_VERSION${suffix}.zip", "$env:SONAR_DIRECTORY/sonar-scanner.zip")
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory("$env:SONAR_DIRECTORY/sonar-scanner.zip", "$env:SONAR_DIRECTORY")
rm ./.sonar/sonar-scanner.zip -Force -ErrorAction SilentlyContinue
$env:SONAR_SCANNER_OPTS="-server"
`;
}
- const suffix = getScannerUrlSuffix(os, arch);
return `export SONAR_SCANNER_VERSION=${SONAR_SCANNER_CLI_LATEST_VERSION}
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION${suffix}
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION${suffix}.zip
import { UserToken } from '../../types/token';
import { Arch, AutoConfig, BuildTools, GradleBuildDSL, OSs, TutorialConfig } from './types';
-export const SONAR_SCANNER_CLI_LATEST_VERSION = '6.0.0.4432';
+export const SONAR_SCANNER_CLI_LATEST_VERSION = '6.1.0.4477';
export function quote(os: string): (s: string) => string {
return os === 'win' ? (s: string) => `"${s}"` : (s: string) => s;
export function getScannerUrlSuffix(os: OSs, arch?: Arch) {
if (os === OSs.Windows) {
- return '-windows';
+ return '-windows-x64';
}
if (os === OSs.MacOS) {
- return '-macosx';
+ return '-macosx-x64';
}
- if (os === OSs.Linux && arch === Arch.X86_64) {
- return '-linux';
+ if (os === OSs.Linux) {
+ return '-linux-' + (arch === Arch.Arm64 ? 'aarch64' : 'x64');
}
return '';
}
-export function showJreWarning(config: TutorialConfig, arch: Arch) {
- if (!isCFamily(config.buildTool)) {
- return false;
- }
- if (config.autoConfig === AutoConfig.Automatic) {
- return false;
- }
- return arch === Arch.Arm64;
+export function shouldFetchBuildWrapper(buildTool: BuildTools, autoConfig?: AutoConfig) {
+ return (
+ (buildTool === BuildTools.Cpp && autoConfig === AutoConfig.Manual) ||
+ buildTool === BuildTools.ObjectiveC
+ );
}
onboarding.analysis.sq_scanner.sonar_token_env.header=Configure a SONAR_TOKEN environment variable in your CI settings
onboarding.analysis.sq_scanner.sonar_token_env.var_name=Add an environment variable called
onboarding.analysis.sq_scanner.sonar_token_env.var_value=Give it the following value
-onboarding.analysis.sq_scanner.jre_required_warning=A compatible Java Runtime Environment is required to run the Scanner on this platform, please refer to {link} for more details.
-onboarding.analysis.sq_scanner.jre_required_warning.link=the documentation
onboarding.analysis.sqscanner.docs.gradle.title=official documentation of the Scanner for Gradle
onboarding.analysis.sqscanner.docs.gradle.example_project.title=live Gradle-based example project