在 Jenkins 2 Pipeline 中执行 SonarQube Scanner [英] Execute SonarQube Scanner within Jenkins 2 Pipeline

查看:34
本文介绍了在 Jenkins 2 Pipeline 中执行 SonarQube Scanner的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的 Jenkins 2.x 管道中执行SonarQube 扫描仪"步骤.

I want to execute a "SonarQube Scanner" Step within my Jenkins 2.x Pipeline.

当我尝试在管道语法中创建示例 groovy 时,我只得到以下格式的 groovy 脚本:

When I try to create a sample groovy within the pipeline-syntax I only get a groovy script of the following format:

step <object of type hudson.plugins.sonar.SonarRunnerBuilder>

有谁知道正确的步骤语法是什么?例如.发布 JUnit 报告的样子

Does anyone know what is the correct Step Syntax? E.g. Publish JUnit Report looks like

step([$class: 'JUnitResultArchiver', testResults: ''])

我使用以下版本:

  • 詹金斯 2.11
  • SonarQube 扫描仪 2.6.1
  • SonarQube 插件 2.4.1

推荐答案

我想我明白了.首先,您必须检索您的 SonarQube 扫描仪工具

I think I got it. First you have to retrieve your SonarQube Scanner Tool

def sonarqubeScannerHome = tool name: 'SonarQubeScanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation'

然后就可以通过 Shell 调用 sonar-scanner:

Then you can call sonar-scanner via Shell:

sh "${sonarqubeScannerHome}/bin/sonar-scanner -e -Dsonar.host.url=..."

这篇关于在 Jenkins 2 Pipeline 中执行 SonarQube Scanner的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆