【问题标题】:Using the external property feature in SonarQube scanner在 SonarQube 扫描仪中使用外部属性功能
【发布时间】:2017-05-09 21:36:41
【问题描述】:

从 SonarQube 扫描器 2.9 版开始,可以从 sonar-project.properties 中引用变量:

https://www.sonarsource.com/resources/product-news/2017/03/2017-03-15-sonarqube-scanner-2.9-released.html

对我来说,此功能的明显用例是避免必须两次声明项目的版本(一次在代码中,一次在 sonar-project.properties 中)。

例如,在 Swift 项目中,版本在 .plist 文件中定义为 XML 值。 有没有明显简单的方法来检索这个值并在sonar-project.properties 文件中引用它?

更新:我已经设法让它在 TeamCity 构建中工作(命令行构建步骤):

echo "##teamcity[setParameter name='env.APP_VERSION' value='$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "MyApp/Info.plist")']"

然后引用sonar-project.properties中的变量:

sonar.projectVersion=${env.APP_VERSION}

【问题讨论】:

    标签: sonarqube sonarqube-scan


    【解决方案1】:

    没有我能想到的“明显简单的方法”。一种方法是使用一个小脚本从 .plist 中选择版本并将其设置为环境变量。然后可以从sonar-project.propertiesbe referenced 的环境变量。

    【讨论】:

      猜你喜欢
      • 2018-04-01
      • 2023-03-11
      • 2017-02-20
      • 2017-04-27
      • 2017-02-12
      • 2018-08-01
      • 2016-12-30
      • 1970-01-01
      • 2018-12-17
      相关资源
      最近更新 更多