field: translate( | field: translate( | ||||
'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.java_installer.java_version' | 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.java_installer.java_version' | ||||
), | ), | ||||
value: '11', | |||||
value: '17', | |||||
})} | })} | ||||
{' ' /* explicit space between the two strings */} | {' ' /* explicit space between the two strings */} | ||||
{translate( | {translate( |
// Jest Snapshot v1, https://goo.gl/fbAQLP | // Jest Snapshot v1, https://goo.gl/fbAQLP | ||||
exports[`should follow and complete all steps: .NET: bitbucket-pipelines.yml 1`] = ` | exports[`should follow and complete all steps: .NET: bitbucket-pipelines.yml 1`] = ` | ||||
"image: mcr.microsoft.com/dotnet/core/sdk:latest | |||||
"image: mcr.microsoft.com/dotnet/sdk:7.0 | |||||
definitions: | definitions: | ||||
steps: | steps: | ||||
- sonar | - sonar | ||||
script: | script: | ||||
- apt-get update | - apt-get update | ||||
- apt-get install --yes openjdk-11-jre | |||||
- apt-get install --yes --no-install-recommends openjdk-17-jre | |||||
- dotnet tool install --global dotnet-sonarscanner | - dotnet tool install --global dotnet-sonarscanner | ||||
- export PATH="$PATH:/root/.dotnet/tools" | - export PATH="$PATH:/root/.dotnet/tools" | ||||
- dotnet sonarscanner begin /k:"my-project" /d:"sonar.token=\${SONAR_TOKEN}" /d:"sonar.host.url=\${SONAR_HOST_URL}" | - dotnet sonarscanner begin /k:"my-project" /d:"sonar.token=\${SONAR_TOKEN}" /d:"sonar.host.url=\${SONAR_HOST_URL}" | ||||
- step: &build-step | - step: &build-step | ||||
name: Build the project, and run the SonarQube analysis | name: Build the project, and run the SonarQube analysis | ||||
script: | script: | ||||
- export SONAR_SCANNER_VERSION=4.6.2.2472 | |||||
- export SONAR_SCANNER_VERSION=5.0.1.3006 | |||||
- mkdir $HOME/.sonar | - mkdir $HOME/.sonar | ||||
- curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip | - 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/ | - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ | ||||
exports[`should follow and complete all steps: CFamily: sonar-project.properties 1`] = `"sonar.projectKey=my-project"`; | exports[`should follow and complete all steps: CFamily: sonar-project.properties 1`] = `"sonar.projectKey=my-project"`; | ||||
exports[`should follow and complete all steps: Gradle: bitbucket-pipelines.yml 1`] = ` | exports[`should follow and complete all steps: Gradle: bitbucket-pipelines.yml 1`] = ` | ||||
"image: openjdk:8 | |||||
"image: eclipse-temurin:17 | |||||
definitions: | definitions: | ||||
steps: | steps: | ||||
`; | `; | ||||
exports[`should follow and complete all steps: Maven: bitbucket-pipelines.yml 1`] = ` | exports[`should follow and complete all steps: Maven: bitbucket-pipelines.yml 1`] = ` | ||||
"image: maven:3-openjdk-11 | |||||
"image: maven:3-eclipse-temurin-17 | |||||
definitions: | definitions: | ||||
steps: | steps: | ||||
- step: &build-step | - step: &build-step | ||||
name: SonarQube analysis | name: SonarQube analysis | ||||
script: | script: | ||||
- pipe: sonarsource/sonarqube-scan:1.0.0 | |||||
- pipe: sonarsource/sonarqube-scan:2.0.1 | |||||
variables: | variables: | ||||
SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable. | SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable. | ||||
SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here. | SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here. |
- step: &build-step | - step: &build-step | ||||
name: Build the project, and run the SonarQube analysis | name: Build the project, and run the SonarQube analysis | ||||
script: | script: | ||||
- export SONAR_SCANNER_VERSION=4.6.2.2472 | |||||
- export SONAR_SCANNER_VERSION=5.0.1.3006 | |||||
- mkdir $HOME/.sonar | - mkdir $HOME/.sonar | ||||
- curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip | - 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/ | - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ |
mainBranchName: string, | mainBranchName: string, | ||||
projectKey: string | projectKey: string | ||||
) { | ) { | ||||
return `image: mcr.microsoft.com/dotnet/core/sdk:latest | |||||
return `image: mcr.microsoft.com/dotnet/sdk:7.0 | |||||
definitions: | definitions: | ||||
steps: | steps: | ||||
- sonar | - sonar | ||||
script: | script: | ||||
- apt-get update | - apt-get update | ||||
- apt-get install --yes openjdk-11-jre | |||||
- apt-get install --yes --no-install-recommends openjdk-17-jre | |||||
- dotnet tool install --global dotnet-sonarscanner | - dotnet tool install --global dotnet-sonarscanner | ||||
- export PATH="$PATH:/root/.dotnet/tools" | - export PATH="$PATH:/root/.dotnet/tools" | ||||
- dotnet sonarscanner begin /k:"${projectKey}" /d:"sonar.token=\${SONAR_TOKEN}" /d:"sonar.host.url=\${SONAR_HOST_URL}" | - dotnet sonarscanner begin /k:"${projectKey}" /d:"sonar.token=\${SONAR_TOKEN}" /d:"sonar.host.url=\${SONAR_HOST_URL}" |
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
export default function gradleExample(branchesEnabled: boolean, mainBranchName: string) { | export default function gradleExample(branchesEnabled: boolean, mainBranchName: string) { | ||||
return `image: openjdk:8 | |||||
return `image: eclipse-temurin:17 | |||||
definitions: | definitions: | ||||
steps: | steps: |
projectKey: string, | projectKey: string, | ||||
projectName: string | projectName: string | ||||
) { | ) { | ||||
return `image: maven:3-openjdk-11 | |||||
return `image: maven:3-eclipse-temurin-17 | |||||
definitions: | definitions: | ||||
steps: | steps: |
- step: &build-step | - step: &build-step | ||||
name: SonarQube analysis | name: SonarQube analysis | ||||
script: | script: | ||||
- pipe: sonarsource/sonarqube-scan:1.0.0 | |||||
- pipe: sonarsource/sonarqube-scan:2.0.1 | |||||
variables: | variables: | ||||
SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable. | SONAR_HOST_URL: \${SONAR_HOST_URL} # Get the value from the repository/workspace variable. | ||||
SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here. | SONAR_TOKEN: \${SONAR_TOKEN} # Get the value from the repository/workspace variable. You shouldn't set secret in clear text here. |
- uses: actions/checkout@v2 | - uses: actions/checkout@v2 | ||||
with: | with: | ||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | ||||
- name: Set up JDK 11 | |||||
- name: Set up JDK 17 | |||||
uses: actions/setup-java@v1 | uses: actions/setup-java@v1 | ||||
with: | with: | ||||
java-version: 1.11 | |||||
java-version: 17 | |||||
- name: Cache SonarQube packages | - name: Cache SonarQube packages | ||||
uses: actions/cache@v1 | uses: actions/cache@v1 | ||||
with: | with: | ||||
- name: Download and install the SonarScanner | - name: Download and install the SonarScanner | ||||
env: | env: | ||||
SONAR_SCANNER_VERSION: 4.6.2.2472 | |||||
SONAR_SCANNER_VERSION: 5.0.1.3006 | |||||
run: | | run: | | ||||
curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${{ env.SONAR_SCANNER_VERSION }}-linux.zip | curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${{ env.SONAR_SCANNER_VERSION }}-linux.zip | ||||
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | ||||
- name: Download and install the SonarScanner | - name: Download and install the SonarScanner | ||||
run: | | run: | | ||||
curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-macosx.zip | |||||
curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-macosx.zip | |||||
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | ||||
- name: Build and analyse the project | - name: Build and analyse the project | ||||
run: | | run: | | ||||
# Potential improvement : add these paths to the PATH env var. | # Potential improvement : add these paths to the PATH env var. | ||||
$HOME/.sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output <your clean build command> | $HOME/.sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output <your clean build command> | ||||
$HOME/.sonar/sonar-scanner-4.6.2.2472-macosx/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output | |||||
$HOME/.sonar/sonar-scanner-5.0.1.3006-macosx/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output | |||||
env: | env: | ||||
SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} | SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} | ||||
SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}" | SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}" | ||||
- name: Download and install the SonarScanner | - name: Download and install the SonarScanner | ||||
shell: powershell | shell: powershell | ||||
run: | | run: | | ||||
$path = "$HOME/.sonar/sonar-scanner-cli-4.6.2.2472-windows.zip" | |||||
$path = "$HOME/.sonar/sonar-scanner-cli-5.0.1.3006-windows.zip" | |||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | ||||
(New-Object System.Net.WebClient).DownloadFile("https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-windows.zip", $path) | |||||
(New-Object System.Net.WebClient).DownloadFile("https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-windows.zip", $path) | |||||
Add-Type -AssemblyName System.IO.Compression.FileSystem | Add-Type -AssemblyName System.IO.Compression.FileSystem | ||||
[System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") | [System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") | ||||
- name: Build and analyse the project | - name: Build and analyse the project | ||||
shell: powershell | shell: powershell | ||||
run: | | run: | | ||||
$env:Path += ";$HOME/.sonar/build-wrapper-win-x86;$HOME/.sonar/sonar-scanner-4.6.2.2472-windows/bin" | |||||
$env:Path += ";$HOME/.sonar/build-wrapper-win-x86;$HOME/.sonar/sonar-scanner-5.0.1.3006-windows/bin" | |||||
build-wrapper-win-x86-64 --out-dir bw-output <your clean build command> | build-wrapper-win-x86-64 --out-dir bw-output <your clean build command> | ||||
sonar-scanner.bat "-Dsonar.cfamily.build-wrapper-output=bw-output" | sonar-scanner.bat "-Dsonar.cfamily.build-wrapper-output=bw-output" | ||||
env: | env: | ||||
- uses: actions/checkout@v2 | - uses: actions/checkout@v2 | ||||
with: | with: | ||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | ||||
- name: Set up JDK 11 | |||||
- name: Set up JDK 17 | |||||
uses: actions/setup-java@v1 | uses: actions/setup-java@v1 | ||||
with: | with: | ||||
java-version: 11 | |||||
java-version: 17 | |||||
- name: Cache SonarQube packages | - name: Cache SonarQube packages | ||||
uses: actions/cache@v1 | uses: actions/cache@v1 | ||||
with: | with: | ||||
- uses: actions/checkout@v2 | - uses: actions/checkout@v2 | ||||
with: | with: | ||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | ||||
- name: Set up JDK 11 | |||||
- name: Set up JDK 17 | |||||
uses: actions/setup-java@v1 | uses: actions/setup-java@v1 | ||||
with: | with: | ||||
java-version: 11 | |||||
java-version: 17 | |||||
- name: Cache SonarQube packages | - name: Cache SonarQube packages | ||||
uses: actions/cache@v1 | uses: actions/cache@v1 | ||||
with: | with: |
- name: Download and install the SonarScanner | - name: Download and install the SonarScanner | ||||
env: | env: | ||||
SONAR_SCANNER_VERSION: 4.6.2.2472 | |||||
SONAR_SCANNER_VERSION: 5.0.1.3006 | |||||
run: | | run: | | ||||
curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${{ env.SONAR_SCANNER_VERSION }}-linux.zip | curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${{ env.SONAR_SCANNER_VERSION }}-linux.zip | ||||
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | ||||
- name: Download and install the SonarScanner | - name: Download and install the SonarScanner | ||||
run: | | run: | | ||||
curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-macosx.zip | |||||
curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-macosx.zip | |||||
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | ||||
- name: Build and analyse the project | - name: Build and analyse the project | ||||
run: | | run: | | ||||
# Potential improvement : add these paths to the PATH env var. | # Potential improvement : add these paths to the PATH env var. | ||||
$HOME/.sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output <your clean build command> | $HOME/.sonar/build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir bw-output <your clean build command> | ||||
$HOME/.sonar/sonar-scanner-4.6.2.2472-macosx/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output | |||||
$HOME/.sonar/sonar-scanner-5.0.1.3006-macosx/bin/sonar-scanner -Dsonar.cfamily.build-wrapper-output=bw-output | |||||
env: | env: | ||||
SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} | SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} | ||||
SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}`, | SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}`, | ||||
- name: Download and install the SonarScanner | - name: Download and install the SonarScanner | ||||
shell: powershell | shell: powershell | ||||
run: | | run: | | ||||
$path = "$HOME/.sonar/sonar-scanner-cli-4.6.2.2472-windows.zip" | |||||
$path = "$HOME/.sonar/sonar-scanner-cli-5.0.1.3006-windows.zip" | |||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | ||||
(New-Object System.Net.WebClient).DownloadFile("https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-windows.zip", $path) | |||||
(New-Object System.Net.WebClient).DownloadFile("https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-windows.zip", $path) | |||||
Add-Type -AssemblyName System.IO.Compression.FileSystem | Add-Type -AssemblyName System.IO.Compression.FileSystem | ||||
[System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") | [System.IO.Compression.ZipFile]::ExtractToDirectory($path, "$HOME/.sonar") | ||||
- name: Build and analyse the project | - name: Build and analyse the project | ||||
shell: powershell | shell: powershell | ||||
run: | | run: | | ||||
$env:Path += ";$HOME/.sonar/build-wrapper-win-x86;$HOME/.sonar/sonar-scanner-4.6.2.2472-windows/bin" | |||||
$env:Path += ";$HOME/.sonar/build-wrapper-win-x86;$HOME/.sonar/sonar-scanner-5.0.1.3006-windows/bin" | |||||
build-wrapper-win-x86-64 --out-dir bw-output <your clean build command> | build-wrapper-win-x86-64 --out-dir bw-output <your clean build command> | ||||
sonar-scanner.bat "-Dsonar.cfamily.build-wrapper-output=bw-output" | sonar-scanner.bat "-Dsonar.cfamily.build-wrapper-output=bw-output" | ||||
env: | env: |
function dotnetYamlSteps(projectKey: string) { | function dotnetYamlSteps(projectKey: string) { | ||||
return ` | return ` | ||||
- name: Set up JDK 11 | |||||
- name: Set up JDK 17 | |||||
uses: actions/setup-java@v1 | uses: actions/setup-java@v1 | ||||
with: | with: | ||||
java-version: 1.11 | |||||
java-version: 17 | |||||
- name: Cache SonarQube packages | - name: Cache SonarQube packages | ||||
uses: actions/cache@v1 | uses: actions/cache@v1 | ||||
with: | with: |
} | } | ||||
const GRADLE_YAML_STEPS = ` | const GRADLE_YAML_STEPS = ` | ||||
- name: Set up JDK 11 | |||||
- name: Set up JDK 17 | |||||
uses: actions/setup-java@v1 | uses: actions/setup-java@v1 | ||||
with: | with: | ||||
java-version: 11 | |||||
java-version: 17 | |||||
- name: Cache SonarQube packages | - name: Cache SonarQube packages | ||||
uses: actions/cache@v1 | uses: actions/cache@v1 | ||||
with: | with: |
function mavenYamlSteps(projectKey: string, projectName: string) { | function mavenYamlSteps(projectKey: string, projectName: string) { | ||||
return ` | return ` | ||||
- name: Set up JDK 11 | |||||
- name: Set up JDK 17 | |||||
uses: actions/setup-java@v1 | uses: actions/setup-java@v1 | ||||
with: | with: | ||||
java-version: 11 | |||||
java-version: 17 | |||||
- name: Cache SonarQube packages | - name: Cache SonarQube packages | ||||
uses: actions/cache@v1 | uses: actions/cache@v1 | ||||
with: | with: |
sonarqube-check: | sonarqube-check: | ||||
stage: sonarqube-check | stage: sonarqube-check | ||||
image: mcr.microsoft.com/dotnet/core/sdk:latest | |||||
image: mcr.microsoft.com/dotnet/sdk:7.0 | |||||
variables: | variables: | ||||
SONAR_USER_HOME: "\${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache | 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 | GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task | ||||
- .sonar/cache | - .sonar/cache | ||||
script: | script: | ||||
- "apt-get update" | - "apt-get update" | ||||
- "apt-get install --yes openjdk-11-jre" | |||||
- "apt-get install --yes --no-install-recommends openjdk-17-jre" | |||||
- "dotnet tool install --global dotnet-sonarscanner" | - "dotnet tool install --global dotnet-sonarscanner" | ||||
- "export PATH=\\"$PATH:$HOME/.dotnet/tools\\"" | - "export PATH=\\"$PATH:$HOME/.dotnet/tools\\"" | ||||
- "dotnet sonarscanner begin /k:\\"my-project\\" /d:sonar.token=\\"$SONAR_TOKEN\\" /d:\\"sonar.host.url=$SONAR_HOST_URL\\" " | - "dotnet sonarscanner begin /k:\\"my-project\\" /d:sonar.token=\\"$SONAR_TOKEN\\" /d:\\"sonar.host.url=$SONAR_HOST_URL\\" " | ||||
sonarqube-check: | sonarqube-check: | ||||
stage: sonarqube-check | stage: sonarqube-check | ||||
image: maven:3.9.3-eclipse-temurin-17 | |||||
image: maven:3-eclipse-temurin-17 | |||||
variables: | variables: | ||||
SONAR_USER_HOME: "\${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache | 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 | GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task | ||||
sonarqube-check: | sonarqube-check: | ||||
stage: sonarqube-check | stage: sonarqube-check | ||||
image: | image: | ||||
name: sonarsource/sonar-scanner-cli:latest | |||||
name: sonarsource/sonar-scanner-cli:5.0 | |||||
entrypoint: [""] | entrypoint: [""] | ||||
variables: | variables: | ||||
SONAR_USER_HOME: "\${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache | SONAR_USER_HOME: "\${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache |
script: () => 'gradle sonar', | script: () => 'gradle sonar', | ||||
}, | }, | ||||
[BuildTools.Maven]: { | [BuildTools.Maven]: { | ||||
image: 'maven:3.9.3-eclipse-temurin-17', | |||||
image: 'maven:3-eclipse-temurin-17', | |||||
script: () => ` | script: () => ` | ||||
- mvn verify sonar:sonar`, | - mvn verify sonar:sonar`, | ||||
}, | }, | ||||
[BuildTools.DotNet]: { | [BuildTools.DotNet]: { | ||||
image: 'mcr.microsoft.com/dotnet/core/sdk:latest', | |||||
image: 'mcr.microsoft.com/dotnet/sdk:7.0', | |||||
script: (projectKey: string) => ` | script: (projectKey: string) => ` | ||||
- "apt-get update" | - "apt-get update" | ||||
- "apt-get install --yes openjdk-11-jre" | |||||
- "apt-get install --yes --no-install-recommends openjdk-17-jre" | |||||
- "dotnet tool install --global dotnet-sonarscanner" | - "dotnet tool install --global dotnet-sonarscanner" | ||||
- "export PATH=\\"$PATH:$HOME/.dotnet/tools\\"" | - "export PATH=\\"$PATH:$HOME/.dotnet/tools\\"" | ||||
- "dotnet sonarscanner begin /k:\\"${projectKey}\\" /d:sonar.token=\\"$SONAR_TOKEN\\" /d:\\"sonar.host.url=$SONAR_HOST_URL\\" " | - "dotnet sonarscanner begin /k:\\"${projectKey}\\" /d:sonar.token=\\"$SONAR_TOKEN\\" /d:\\"sonar.host.url=$SONAR_HOST_URL\\" " | ||||
}, | }, | ||||
[BuildTools.Other]: { | [BuildTools.Other]: { | ||||
image: ` | image: ` | ||||
name: sonarsource/sonar-scanner-cli:latest | |||||
name: sonarsource/sonar-scanner-cli:5.0 | |||||
entrypoint: [""]`, | entrypoint: [""]`, | ||||
script: () => ` | script: () => ` | ||||
- sonar-scanner`, | - sonar-scanner`, |
`; | `; | ||||
exports[`can choose build tools and copy provided settings: cfamily linux: execute scanner 1`] = ` | exports[`can choose build tools and copy provided settings: cfamily linux: execute scanner 1`] = ` | ||||
"export SONAR_SCANNER_VERSION=4.7.0.2747 | |||||
"export SONAR_SCANNER_VERSION=5.0.1.3006 | |||||
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux | 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 | 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 | ||||
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | ||||
`; | `; | ||||
exports[`can choose build tools and copy provided settings: cfamily macos: execute scanner 1`] = ` | exports[`can choose build tools and copy provided settings: cfamily macos: execute scanner 1`] = ` | ||||
"export SONAR_SCANNER_VERSION=4.7.0.2747 | |||||
"export SONAR_SCANNER_VERSION=5.0.1.3006 | |||||
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-macosx | 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 | 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 | ||||
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | ||||
`; | `; | ||||
exports[`can choose build tools and copy provided settings: cfamily windows: execute scanner 1`] = ` | exports[`can choose build tools and copy provided settings: cfamily windows: execute scanner 1`] = ` | ||||
"$env:SONAR_SCANNER_VERSION = "4.7.0.2747" | |||||
"$env:SONAR_SCANNER_VERSION = "5.0.1.3006" | |||||
$env:SONAR_DIRECTORY = [System.IO.Path]::Combine($(get-location).Path,".sonar") | $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" | ||||
rm $env:SONAR_SCANNER_HOME -Force -Recurse -ErrorAction SilentlyContinue | rm $env:SONAR_SCANNER_HOME -Force -Recurse -ErrorAction SilentlyContinue | ||||
`; | `; | ||||
exports[`can choose build tools and copy provided settings: other linux: execute scanner 1`] = ` | exports[`can choose build tools and copy provided settings: other linux: execute scanner 1`] = ` | ||||
"export SONAR_SCANNER_VERSION=4.7.0.2747 | |||||
"export SONAR_SCANNER_VERSION=5.0.1.3006 | |||||
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux | 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 | 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 | ||||
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | ||||
`; | `; | ||||
exports[`can choose build tools and copy provided settings: other macos: execute scanner 1`] = ` | exports[`can choose build tools and copy provided settings: other macos: execute scanner 1`] = ` | ||||
"export SONAR_SCANNER_VERSION=4.7.0.2747 | |||||
"export SONAR_SCANNER_VERSION=5.0.1.3006 | |||||
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-macosx | 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 | 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 | ||||
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | ||||
`; | `; | ||||
exports[`can choose build tools and copy provided settings: other windows: execute scanner 1`] = ` | exports[`can choose build tools and copy provided settings: other windows: execute scanner 1`] = ` | ||||
"$env:SONAR_SCANNER_VERSION = "4.7.0.2747" | |||||
"$env:SONAR_SCANNER_VERSION = "5.0.1.3006" | |||||
$env:SONAR_DIRECTORY = [System.IO.Path]::Combine($(get-location).Path,".sonar") | $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" | ||||
rm $env:SONAR_SCANNER_HOME -Force -Recurse -ErrorAction SilentlyContinue | rm $env:SONAR_SCANNER_HOME -Force -Recurse -ErrorAction SilentlyContinue |
function getRemoteDownloadSnippet(os: OSs) { | function getRemoteDownloadSnippet(os: OSs) { | ||||
if (os === OSs.Windows) { | if (os === OSs.Windows) { | ||||
return `$env:SONAR_SCANNER_VERSION = "4.7.0.2747" | |||||
return `$env:SONAR_SCANNER_VERSION = "5.0.1.3006" | |||||
$env:SONAR_DIRECTORY = [System.IO.Path]::Combine($(get-location).Path,".sonar") | $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" | ||||
rm $env:SONAR_SCANNER_HOME -Force -Recurse -ErrorAction SilentlyContinue | rm $env:SONAR_SCANNER_HOME -Force -Recurse -ErrorAction SilentlyContinue | ||||
`; | `; | ||||
} | } | ||||
const suffix = os === OSs.MacOS ? 'macosx' : 'linux'; | const suffix = os === OSs.MacOS ? 'macosx' : 'linux'; | ||||
return `export SONAR_SCANNER_VERSION=4.7.0.2747 | |||||
return `export SONAR_SCANNER_VERSION=5.0.1.3006 | |||||
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-${suffix} | 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 | 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 | ||||
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ |