如何从sonarqube API获取项目语言?
如何使用SonarqubeAPI获取项目的主编程语言?或者是项目所有编程语言的列表?每个SonarQube: ncloc_语言分布-按语言分布的非注释代码行如何从sonarqube API获取项目语言?,sonarqube,Sonarqube,如何使用SonarqubeAPI获取项目的主编程语言?或者是项目所有编程语言的列表?每个SonarQube: ncloc_语言分布-按语言分布的非注释代码行 将其与SonarQube WebAPI/measures(SonarQube服务器中的文档)一起使用,您应该可以很好地使用。为了解决同样的问题,我提出了一个小的shell脚本,该脚本编写了所有SonarQube项目密钥的列表以及给定项目的语言分布: #!/bin/bash API="http://my.sonar-server.com:9
将其与SonarQube WebAPI/measures(SonarQube服务器中的文档)一起使用,您应该可以很好地使用。为了解决同样的问题,我提出了一个小的shell脚本,该脚本编写了所有SonarQube项目密钥的列表以及给定项目的语言分布:
#!/bin/bash
API="http://my.sonar-server.com:9000/sonar/api" ### adjust this!
API_LANG_DIST="$API/measures/component?metricKeys=ncloc_language_distribution"
# get a list of all project keys:
projKeys=$(curl -s "$API/projects/index" | jq -r '.[].k')
# for each project key, get the language distribution metric:
for key in ${projKeys}; do
langDist=$(curl -s "${API_LANG_DIST}&componentKey=${key}" | jq '.component.measures[0].value')
printf "%-80s%-80s\n" ${key} ${langDist}
done
输出如下所示:
com.mycompany:projectA "grvy=75;java=4091"
com.mycompany:projectB "css=1966;java=52770;js=11460;less=1862"
com.mycompany:projectC "css=40185;java=11451;js=13757"
注意:此脚本使用了jq
JSON解析实用程序。如果没有,可以通过sudo-yum-install-jq
进行安装
(在SonarQube 5.6.6和6.7.0上测试)谢谢,这正是我想要的!我的用法:api/measures/component?componentKey=[key]&metricKeys=ncloc\u language\u发行版