有沒有辦法突破的時候聲納質量門與waitForQualityGate()方法失敗,聲納掃描儀沿着MSBuild的詹金斯建?我找不到任何相同的文檔。我所能找到的只是使用waitForQualityGate()和Sonar掃描儀,但不推薦使用通用聲納掃描儀進行MSbuild項目。waitForQualityGate()與聲納掃描儀的MSBuild
下面提到的鏈接並沒有提及使用waitForQualityGate和MSBuild。 https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Jenkins#AnalyzingwithSonarQubeScannerforJenkins-AnalyzinginaJenkinspipeline
該文件談到了聲納掃描儀,但我指的是完全不同的掃描儀MSbuild的聲納掃描儀。我使用這種掃描儀的方式如下所示。
void beginSonarMSBuild(String VERSION){
stage('Begin Sonar Analysis') {
def MSBuildScannerHome = tool 'sonar-scanner-msbuild-3.0.0.629';
withSonarQubeEnv('civil sonar') {
bat "${MSBuildScannerHome}\\SonarQube.Scanner.MSBuild.exe begin /k:mcdc
/n:mc-design-converter /v:${VERSION}.$BUILD_NUMBER /d:sonar.sourceEncoding=UTF-8
}
}
}
void build(){
stage ('Build'){
bat "Nuget restore SOMEHTING.sln"
bat "MSBuild.exe SOMETHING.csproj "
}
}
void endSonarMSBuild(){
stage ('Complete Sonar Analysis'){
def MSBuildScannerHome = tool 'sonar-scanner-msbuild-3.0.0.629';
bat "${MSBuildScannerHome}\\SonarQube.Scanner.MSBuild.exe end"
}
}
現在,當我使用waitforqualitygate()
與beginSonarMSBuild(String VERSION)
如下圖所示:
void beginSonarMSBuild(String VERSION){
stage('Begin Sonar Analysis') {
def MSBuildScannerHome = tool 'sonar-scanner-msbuild-3.0.0.629';
withSonarQubeEnv('civil sonar') {
bat "${MSBuildScannerHome}\\SonarQube.Scanner.MSBuild.exe begin /k:mcdc
/n:mc-design-converter /v:${VERSION}.$BUILD_NUMBER /d:sonar.sourceEncoding=UTF-8
}
}
stage("Quality Gate"){
timeout(time: 1, unit: 'MINUTES') {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
void build(){
scripts here...
}
void endSonarMSBuild(){
scripts here...
}
我得到這個錯誤味精java.lang.IllegalStateException: Unable to get SonarQube task id and/or server name. Please use the 'withSonarQubeEnv' wrapper to run your analysis.
我也得到了同樣的錯誤,當我使用waitForQualityGate()
與endSonarMSBuild()
步如圖所示下面。
void beginSonarMSBuild(String VERSION){
stage('Begin Sonar Analysis') {
scripts here...
}
void build(){
scripts here...
}
void endSonarMSBuild(){
stage ('Complete Sonar Analysis'){
def MSBuildScannerHome = tool 'sonar-scanner-msbuild-3.0.0.629';
bat "${MSBuildScannerHome}\\SonarQube.Scanner.MSBuild.exe end"
}
stage("Quality Gate"){
timeout(time: 1, unit: 'MINUTES') {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
所以我是這個問題,並聲納掃描儀的MSBuild甚至支持waitForQualityGate()
,如果是的話,那麼如何使用相同的?
我真的不明白你的問題。該但是當代碼沒有通過聲納質量門時,buil會自動失敗,並且waitForQualityGate()是正確的方法 – arifCee
但是,在何處使用waitForQualityGate()?作爲「SonarQube.Scanner.MSBuild.exe開始」或「SonarQube .Scanner.MSBuild.exe結束'步驟?請注意''聲納掃描儀'是不同於'聲吶掃描儀的MSbuild' –