如何在没有Maven和Docker的情况下在Jenkins声明式管道中执行SonarQube扫描器 [英] How to execute SonarQube scanner in Jenkins Declarative Pipeline without Maven and Docker

查看:179
本文介绍了如何在没有Maven和Docker的情况下在Jenkins声明式管道中执行SonarQube扫描器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SonarQube扫描仪是否支持不带有maven和docker的BlueOcean管道插件,如果该脚本如何在Jenkinsfile中起作用?

Does SonarQube scanner support BlueOcean pipeline plugin without maven and docker, if it does how does the script works in Jenkinsfile?

我是Jenkins和BlueOcean的新手,并尝试了所有可能的基本方面.

I'm new to Jenkins and BlueOcean and have tried all the basic possible aspects available.

如果SonarQube插件确实支持声明式:

If the SonarQube plugin did support Declarative:

pipeline {
  agent any
  stages {
    stage('SonarQube analysis') {
      tools {
        sonarQube 'SonarQube Scanner 2.8'
      }
      steps {
        withSonarQubeEnv('SonarQube Scanner') {
          sh 'sonar-scanner'
        }
      }
    }
  }
}

推荐答案

解决了一个问题,只需要检查常规工具配置中的工具位置,并在jenkins文件中提供路径并调用它即可.

it is solved one just need to check the tool location in general tool configs and give the path adn call it in jenkins file.

 stage('PDNS-UI-Sonar') { 
         environment {
             SONAR_SCANNER_OPTS = "-Xmx2g"
             } 
         steps {
             sh "pwd"
             sh "/opt/sonar-scanner/bin/sonar-scanner -Dproject.settings=sonar-project.properties"
             }
         }

在此处输入图片描述

这篇关于如何在没有Maven和Docker的情况下在Jenkins声明式管道中执行SonarQube扫描器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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