2017-06-27 58 views
0

當我嘗試使用SonarQube.Scanner.MSBuild.exe與像開關:如何使用與SonarQube.Scanner.MSBuild.exe Gitlab變量gitlab-ci.yml內

SonarQube.Scanner.MSBuild.exe /k:%CI_COMMIT_REF_NAME% /n:%CI_COMMIT_REF_NAME% 

日誌轉儲給我帶來%CI_COMMIT_REF_NAME%的問題。就好像他們不存在或者他們找不到。

我也看到了這條線在文件的結尾:

'GitLab Commit Issue Publisher' skipped because one of the required properties is missing 

這裏是我的SonarQube.Analysis.xml文件

<SonarQubeAnalysisProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sonarsource.com/msbuild/integration/2015/1"> 
<!-- The sonarqube server address --> 
    <Property Name="sonar.host.url">http://server.com:1234</Property> 

     <Property Name="sonar.sourceEncoding">UTF-8</Property>  

     <!-- I have no idea if anything below this line works --> 
    <!-- <Property Name="sonar.projectName">Master</Property> Should be set in job of the gitlab yml 
     <Property Name="sonar.projectKey">Master</Property> Should be set in job of the gitlab yml --> 
     <Property Name="sonar.exclusions">folder\**</Property> 
     <Property Name="sonar.sources">.</Property> 
     <Property Name="sonar.verbose">true</Property> 
    <!-- <Property Name="sonar.scanner.dumpToFile">somethingWentWrong.txt</Property> --> 
     <Property Name="sonar.analysis.mode">issues</Property> 


     <!-- 
    this is only for forced authentication. the group "everyone" on the server has execute permission so you don't need to fill this out. 
     <Property Name="sonar.login"></Property> 
     <Property Name="sonar.password"></Property> 
     --> 


    </SonarQubeAnalysisProperties> 

這裏是我用來調用SonarQube命令序列。 Scanner.MSbuild.exe在gitlab-ci.yml工作:

- SonarQube.Scanner.MSBuild.exe begin /k:doesthiswork /n:doesthiswork 
- MSBuild.exe /t:Rebuild directory\Solution.sln 
- SonarQube.Scanner.MSBuild.exe end 

我怎麼不知道如何使用Gitlab predfi SonarQube.Scanner.MSBuild.exe中的ned變量在Gitlab-ci.yml中調用?

gitlab變量:https://docs.gitlab.com/ee/ci/variables/#predefined-variables-environment-variables

回答

0

Gitlab和sonarqube變量均可使用;但它們不能從gitlab-ci.yml中引用。

在gitlab-ci.yml撥打電話到一個批處理腳本,例如:

- cmd.exe /c callMyBatch.bat 

.... callMyBatch.bat

SonarQube.Scanner.MSBuild.exe begin /k:%GITLABORENVIRONMENTVAR% 
MSBuild.exe /t:Rebuild directory\Solution.sln 
SonarQube.Scanner.MSBuild.exe end 
+0

沒有人將要回答的裏面,感謝fam。 –