【问题标题】:How do I use Gitlab variables with SonarQube.Scanner.MSBuild.exe inside of a gitlab-ci.yml如何在 gitlab-ci.yml 中使用带有 SonarQube.Scanner.MSBuild.exe 的 Gitlab 变量
【发布时间】:2017-11-30 23:26:11
【问题描述】:

当我尝试使用带有以下开关的 SonarQube.Scanner.MSBuild.exe 时:

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>

这是我在 gitlab-ci.yml 作业中调用 SonarQube.Scanner.MSbuild.exe 的命令序列:

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

关于在 Gitlab-ci.yml 内部的 SonarQube.Scanner.MSBuild.exe 调用中使用 Gitlab 预定义变量,我有什么不明白的地方?

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

【问题讨论】:

    标签: .net msbuild sonarqube gitlab sonarqube-scan


    【解决方案1】:

    可以使用 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
    

    【讨论】:

      猜你喜欢
      • 2023-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-31
      • 2019-09-27
      • 2016-02-29
      • 2022-06-23
      • 2023-02-02
      相关资源
      最近更新 更多