Linux教程

Jenkins集成Sonar(流水线项目)

本文主要是介绍Jenkins集成Sonar(流水线项目),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

 

 

 

 

 

 

 

 

 

sonar.projectKey=sp0706_demo01
sonar.projectName=sp0706_demo01
sonar.projectVersion=1.0
sonar.sources=.
sonar.exclusions=**/test/**,**/target/**
sonar.java.source=1.8
sonar.java.target=1.8
sonar.sourceEncoding=UTF-8

  

8.修改Jenkinsfile

pipeline {
    agent any
    stages {
        stage('pull project') {
            steps {
               checkout([$class: 'GitSCM', branches: [[name: '*/${branch}']], extensions: [], userRemoteConfigs: [[credentialsId: 'f193a0fe-6350-48a4-9329-5c02a4012d45', url: 'git@192.168.233.140:kgc_group/web_demo.git']]])
            }
        }
        stage('code checking') {
             steps {
                script {
                    scannerHome = tool 'sonar-scanner'
                }
                withSonarQubeEnv('sonarqube') {
                    sh "${scannerHome}/bin/sonar-scanner"
                }
             }
        }
        stage('build project') {
            steps {
                sh 'mvn clean package'
            }
        }
        stage('publish project') {
            steps {
                deploy adapters: [tomcat8(credentialsId: '07cc8263-ec37-4383-8b0b-1193c8256376', path: '', url: 'http://192.168.233.141:8080')], contextPath: null, war: 'target/*.war'
            }
        }
    }
}

  

 

 

public class Demo01 {
    public static void main(String[] args) {

        int count  = 4/0;
        System.out.println(count);
    }
}

  

这篇关于Jenkins集成Sonar(流水线项目)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!