pipeline {
    agent any
    stages {
        stage('SCM') {
            steps {
                git 'git@git.zhiweidata.top:root/print-demo.git'
            }
        }
        stage('build && SonarQube analysis') {
            steps {
                withSonarQubeEnv('sonar') {

                        sh 'mvn clean package sonar:sonar'

                }
            }
        }
        stage("Quality Gate") {
            steps {
                timeout(1) {
                    waitForQualityGate abortPipeline: true
                }
            }
            post {
                success {
                    sh "/usr/local/bin/workwechatctl -p ${env.JOB_NAME} -n 张金晓 -c 代码检测通过"
                }
                failure {
                    sh "/usr/local/bin/workwechatctl -p ${env.JOB_NAME} -n 张金晓 -c 代码检测失败，请登陆sonar查看项目失败信息。"
                }
            }

        }
    }
}