SonarQube with Jenkins pipeline

  1. Install SonarQube Scanner plugin in Jenkins.
  2. Global Configuration.
    Log into Jenkins as an administrator and go to Manage Jenkins > Global Tool Configuration:
  3. Create Pipeline job.
    Add the below Pipeline script:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    node {
    def mvnHome
    stage('SCM and configration') {

    git 'https://github.com/yongfeiuall/spring-boot-example.git'
    mvnHome = tool 'M3'
    }
    stage('SonarQube analysis') {
    withSonarQubeEnv('SonarQube') {
    sh "'${mvnHome}/bin/mvn' clean package sonar:sonar"
    } // SonarQube taskId is automatically attached to the pipeline context
    }
    }
  4. Run job.

唐胡璐 wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!
分享创造价值,您的支持将鼓励我继续前行!