Bhu*_*tam 21 continuous-integration static-analysis jenkins sonarqube
问题:我正在通过声纳设置jenkins + sonar + github集成以进行自动pullrequest静态代码检查.
我的配置:
用github安装Sonar
安装了詹金斯
在jenkins post-build动作中,我有以下属性
Run Code Online (Sandbox Code Playgroud)-Dsonar.github.login=bhuwang -Dsonar.github.repository=company/repo -Dsonar.verbose=true -Dsonar.analysis.mode=preview -Dsonar.issuesReport.console.enable=true -Dsonar.forceUpdate=true -Dsonar.github.login=gitusername -Dsonar.github.oauth=token
在这个链接中,我已经读过在运行sonarqube时我必须提供以下属性:
我添加了除sonar.github.pullRequest属性之外的所有属性.我不知道如何动态获取此属性值.似乎以上四个属性必须正常工作.
编辑:我找到了添加属性的方法-Dsonar.github.pullRequest = pullrequestNo
好消息是,现在使用硬编码拉取请求没有完美的工作.但我需要动态的方式来获取拉请求.
有谁知道怎么得到拉请求没有.动态地在詹金斯里面.?
我发现拉请求构建器可以工作,但我的运气没有运气.我无法在声纳属性中使用拉请求构建器环境变量.
Bhu*_*tam 28
最后,我能够解决这个问题.这是详细信息:
使用以下插件安装Jenkins
点击此链接设置拉取请求构建器插件:https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin#GitHubpullrequestbuilderplugin-EnvironmentVariables
Run Code Online (Sandbox Code Playgroud)-Dsonar.sourceEncoding=UTF-8 -Dsonar.analysis.mode=preview -Dsonar.github.repository=company/repo -Dsonar.github.login=gitusername -Dsonar.github.oauth=oauthtoken -Dsonar.host.url=sonarhostedurl -Dsonar.login=admin -Dsonar.password=pass -Dsonar.github.pullRequest=${ghprbPullId} ${ghprbPullId}: this will be provided via github pullrequest builder plugin
注意:应该通过pullrequest builder插件触发作业,否则$ {ghprbPullId}将返回空白.如果您手动运行该作业,则无法将此$ {ghprbPullId}属性作为构建参数传递.如果要检查可用的环境参数,请遵循此Git环境变量以用于执行Jenkins shell脚本
我希望这有帮助.