您好,登錄后才能下訂單哦!
這篇文章給大家介紹使用pipeline怎么自動化配置sonar,內容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
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' } }
關于使用pipeline怎么自動化配置sonar就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。