通过pipeline配置sonar自动化实现过程解析
程序员文章站
2022-07-08 10:02:55
1.sonar配置webhooks,2.url填写jenkins的地址:http://jenkinsurl/sonarqube-webhook/3.前提:jenkins配置好sonar的scanner...
1.sonar配置webhooks,
2.url填写jenkins的地址:http://jenkinsurl/sonarqube-webhook/
3.前提:jenkins配置好sonar的scanner服务地址
node { stage('gitcheckout') { echo 'this is a gitcheckout step' checkout poll: false, scm: [$class: 'gitscm', branches: [[name: '*/master']], dogeneratesubmoduleconfigurations: false, extensions: [], submodulecfg: [], userremoteconfigs: [[credentialsid: 'git-', url: 'http://gitlab..com/qingzhu-dev/workflow.git']]] } stage('sonar') { echo 'this is a sonar step' def sonarqubescannerhome = tool name: 'sonar-scanner' echo sonarqubescannerhome withsonarqubeenv('sonar') { sh "${sonarqubescannerhome}/bin/sonar-scanner -x "+ "-dsonar.host.url=${sonar_host_url} " + "-dsonar.language=java " + "-dsonar.projectkey=workflow " + "-dsonar.projectname=workflow " + "-dsonar.projectversion=$build_number " + "-dsonar.sources=src/ " + "-dsonar.sourceencoding=utf-8 " + "-dsonar.java.binaries=target/ " + "-dsonar.exclusions=src/test/** " } } stage("qualitygate") { echo 'qualitygate' // timeout(time: 1, unit: "hours") { // 防止获取回调出现异常情况,设置超时时间 // def qg = waitforqualitygate() // if (qg.status != 'ok') { // error "pipeline aborted due to quality gate failure: ${qg.status}" // } // } } stage('build') { echo 'this is a build step' sh "/var/jenkins_home/apache-maven-3.6.0/bin/mvn clean package -u dockerfile:build dockerfile:push -ptest -d maven.test.skip=true -f pom.xml -dimage.tag=v$build_number" } stage('deploy') { echo 'this is a deploy step' sh "${dp}" } stage('test') { echo 'this is a test step' checkout poll: false, scm: [$class: 'gitscm', branches: [[name: '*/qiaojiafei']], dogeneratesubmoduleconfigurations: false, extensions: [], submodulecfg: [], userremoteconfigs: [[credentialsid: 'git-', url: 'http://gitlab..com/qz-qa/qingzhucrmtest.git']]] sh '/var/jenkins_home/apache-maven-3.6.0/bin/mvn clean test -dfailifnotests=false -ptest' } stage('report'){ echo 'this is a report' allure includeproperties: false, jdk: 'jdk1.8', results: [[path: 'allure-results']] sh 'rm -rf allure-report' sh 'rm -rf allure-results' } stage('email'){ emailext body: 'test', subject: 'test', to: 'gexinwei@meizhu365.com' } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
上一篇: Keras_tutorial-NeuralNetwork
下一篇: 电动车哪来的挡风玻璃