azure - 如何为 Sonar Qube 编写 Gitlab 管道作业
问题描述
嗨,就我而言,我使用 Gitlab 社区和 Sonar Qube。Sonar 托管在带有 Docker 容器的 Azure Ubuntu VM 上。在我的 Sonar 在 Windows 机器上之前,这里是 gitlab.yml 的一部分。
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:
- build
- test
before_script:
- Set-Variable -Name "time" -Value (Get-Date -Format "%H:%m")
- echo ${time}
- echo "started by ${GITLAB_USER_NAME}"
build:
stage: build
only:
- branches
script:
- echo "running scripts in the build job"
- choco feature enable -n=allowGlobalConfirmation
- choco install netfx-4.6.2-devpack
- choco install dotnetcore-sdk
- nuget restore -ConfigFile .\nuget.config
- msbuild ".\MyProject\MyProject.csproj" /p:DeployOnBuild=true /p:PublishProfile="Local Publish" /p:WarningLevel=0
- dotnet build ".\MyProject.Tests\MyProject.Tests.csproj" --configuration Release
artifacts:
paths:
- Publish
- .\MyProject.Tests\bin\Release\netcoreapp3.1\**
- .\MyProject
expire_in: 1 day
after_script:
- Remove-Item -Recurse -Force .\packages\
sonarcloud-check:
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
dependencies:
- build
script:
- choco install sonarqube-scanner.portable
- SonarScanner.MSBuild.exe begin /k:"myProject" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="8f6658e7684de225a4f45c7cf3466d462a95c1c7"
- nuget restore -ConfigFile .\nuget.config
- MsBuild.exe ./MyProject /t:Rebuild
- SonarScanner.MSBuild.exe end /d:sonar.login="8f6658e7684de225a4f45c7cf3466d462a95c1c7"
only:
- merge_requests
- master
- develop
- GitLabQualityTool
我知道这个 yml 不是最好的,但它的工作。主要项目在 .net 4.6.2 上。Sonar 在 Ubuntu 上运行,端口为 80:9000。关键是我一周前就开始使用 Azure、Docker 和 Sonar。有人可以帮我配置 yml 吗?
解决方案
推荐阅读
- ios - 使用 Swift 在 Firebase 中进行 GeoHash 查询
- excel - Excel VBA AutoFilter 选择过滤器等于 key1 和 key2 最小值的行
- javascript - 如何从后台注入内容脚本
- mysql - 如何重写它以删除选择语句连接?
- matlab - 无旋转的带状矩阵版本的高斯消元法
- apache-spark - Databricks 光子与催化剂优化器
- r - Apply a req statement to multiple outputs
- reactjs - Eslint 没有显示警告 - 反应
- powershell - 使用 PowerShell 生成 Azure 存储帐户 SAS 密钥
- javascript - react 未被识别为内部或外部命令或可运行程序或批处理文件