共用方式為


SonarQubePrepare@4 - 準備分析組態 v4 工作

使用此工作來準備 SonarQube 分析組態。

Syntax

# Prepare Analysis Configuration v4
# Prepare SonarQube analysis configuration.
- task: SonarQubePrepare@4
  inputs:
    SonarQube: # string. Required. SonarQube Server Endpoint. 
    scannerMode: 'MSBuild' # 'MSBuild' | 'Other' | 'CLI'. Required. Choose the way to run the analysis. Default: MSBuild.
    #configMode: 'file' # 'file' | 'manual'. Required when scannerMode = CLI. Mode. Default: file.
    #configFile: 'sonar-project.properties' # string. Optional. Use when scannerMode = CLI && configMode = file. Settings File. Default: sonar-project.properties.
    #cliProjectKey: # string. Required when scannerMode = CLI && configMode = manual. Project Key. 
    projectKey: # string. Required when scannerMode = MSBuild. Project Key. 
    #cliProjectName: # string. Optional. Use when scannerMode = CLI && configMode = manual. Project Name. 
    #projectName: # string. Optional. Use when scannerMode = MSBuild. Project Name. 
    #cliProjectVersion: '1.0' # string. Optional. Use when scannerMode = CLI && configMode = manual. Project Version. Default: 1.0.
    #projectVersion: '1.0' # string. Optional. Use when scannerMode = MSBuild. Project Version. Default: 1.0.
    #cliSources: '.' # string. Required when scannerMode = CLI && configMode = manual. Sources directory root. Default: ..
  # Advanced
    #extraProperties: # string. Additional Properties.

輸入

SonarQube - SonarQube 伺服器端點
string. 必要。

指定您專案的 SonarQube 伺服器端點。 若要建立一個,請按一下 Manage 連結、建立新的 SonarQube 伺服器端點,然後輸入您的伺服器 URL 和權杖。


scannerMode - 選擇執行分析的方式
string. 必要。 允許的值: MSBuild (與 MSBuild) 整合、 Other (與 Maven 或 Gradle) 整合, CLI (使用獨立掃描器) 。 預設值:MSBuild

MSBuild

  • 將此工作放在 MSBuild 工作之前。
  • 在 MSBuild/VSTest 工作之後新增工作 Run Code Analysis

Maven/Gradle

  • 將此工作放在 Maven/Gradle 工作之前。
  • Run SonarQube Analysis勾選 Maven/Gradle 工作設定中的核取方塊。

其他

  • 在其他情況下,您可以使用獨立掃描器 (sonar-scanner) 、設定此工作的所有組態,然後新增工作 Run Code Analysis

configMode - 模式
string. 需要 。 scannerMode = CLI 允許的值: file (使用我的原始程式碼儲存組態, (sonar-project.properties) ) , manual (手動提供組態) 。 預設值:file

指定您慣用的組態方法。


configFile - 設定檔
string. 選擇性。 使用 時 scannerMode = CLI && configMode = file 。 預設值:sonar-project.properties

指定組態設定和專案屬性。 深入瞭解 適用于 Azure DevOps 的 SonarQube 擴充功能


cliProjectKey - 專案索引鍵
string. 需要 。 scannerMode = CLI && configMode = manual

指定 SonarQube 專案唯一索引鍵。 例如: sonar.projectKey


projectKey - 專案索引鍵
string. 需要 。 scannerMode = MSBuild

指定 SonarQube 專案唯一索引鍵。 例如: sonar.projectKey


cliProjectName - 專案名稱
string. 選擇性。 使用 時 scannerMode = CLI && configMode = manual

指定 SonarQube 專案名稱。 例如: sonar.projectName


projectName - 專案名稱
string. 選擇性。 使用 時 scannerMode = MSBuild

指定 SonarQube 專案名稱。 例如: sonar.projectName


cliProjectVersion - 專案版本
string. 選擇性。 使用 時 scannerMode = CLI && configMode = manual 。 預設值:1.0

指定 SonarQube 專案版本。 例如: sonar.projectVersion


projectVersion - 專案版本
string. 選擇性。 使用 時 scannerMode = MSBuild 。 預設值:1.0

指定 SonarQube 專案版本。 例如: sonar.projectVersion


cliSources - 來原始目錄根目錄
string. 需要 。 scannerMode = CLI && configMode = manual 預設值:.

指定包含來源檔案之根目錄的路徑。 此值設定為 sonar.sources SonarQube 屬性。


extraProperties - 其他屬性
string. 預設值:# Additional properties that will be passed to the scanner, \n# Put one key=value per line, example:\n# sonar.exclusions=**/*.bin

指定要傳遞至掃描器 的其他屬性 。 在新行上指定每 key=value 一組。


工作控制項選項

除了工作輸入之外,所有工作都有控制選項。 如需詳細資訊,請參閱 控制選項和一般工作屬性

輸出變數

無。

備註

  • 支援非 MSBuild 專案: 這項工作也可以設定非 MSBuild 專案的分析。

規格需求

需求 說明
管線類型 YAML、傳統組建
在 上執行 Agent、DeploymentGroup
要求
Capabilities 此工作不符合作業中後續工作的任何需求。
命令限制 任意
可設定變數 任意
代理程式版本 1.95.1 或更新版本
工作類別 建置

另請參閱