SonarQube是一款靜態代碼分析、代碼質量度量和漏洞檢測的開源代碼質量管理平臺,它提供了許多功能,包括靜態代碼分析、代碼覆蓋率、復雜度分析、漏洞檢測等。SonarQube可以集成到許多流行的編程語言和集成開發環境中,幫助開發人員創建高質量的軟件項目。SonarQube以及依賴環境軟件的安裝已經在此系列文章的第一篇寫過,這里只介紹如何配置和使用Jenkins+SonarQube進行代碼質量檢查。
流水線腳本如下:
node { def mvnHome stage('Preparation') { // for display purposes // Get some code from a GitHub repository echo "checkout from GitLab" checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[credentialsId: 'git_username', url: 'http://127.0.0.1:9091/test/test.git']]) // Get the Maven tool. // ** NOTE: This 'M3' Maven tool must be configured // ** in the global configuration. mvnHome = tool 'maven_j' } stage('SonarQube Analysis') { echo "sonar test code" withEnv(["MVN_HOME=$mvnHome"]) { withSonarQubeEnv() { sh "'$MVN_HOME/bin/mvn' clean verify sonar:sonar -Dsonar.projectKey=sonarTest -Dsonar.projectName='Sonar質量檢查'" } } } stage('Build') { echo "build test code" // Run the maven build withEnv(["MVN_HOME=$mvnHome"]) { if (isUnix()) { sh '"$MVN_HOME/bin/mvn" -Dmaven.test.failure.ignore clean package' } else { bat(/"%MVN_HOME%/bin/mvn" -Dmaven.test.failure.ignore clean package/) } } } stage('Results') { echo "end sonar testcode" //junit '**/target/surefire-reports/TEST-*.xml' // archiveArtifacts 'target/*.jar' }}
本文鏈接:http://www.www897cc.com/showinfo-26-13518-0.html微服務部署—配置Jenkins+SonarQube進行代碼質量檢查
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。郵件:2376512515@qq.com
上一篇: Java機器視覺:利用OpenCV進行圖像處理和識別
下一篇: 如何搭建高性能廣告技術需求方平臺