[英]How to integrate SonarCloud with GitHub and Jenkins
我剛剛結束了我與 Jenkins 的 GitHub 集成,這樣每次我將代碼提交到我的 GitHub 存儲庫時,Jenkins 都會自動構建。 現在我也在嘗試集成 SonarCloud,但我還沒有成功。 我不想與本地 SonarQube 服務器集成,我真的需要 SonarCloud 讓我的團隊在每次 Jenkins 構建時檢查它。
我不確定是否應該在本地分析項目來實現這一點,或者我是否可以分析我的 Jenkins 服務器或 GitHub 存儲庫並獲得我想要的結果,因為我找不到任何文檔。
任何人都可以指出我正確的方向嗎?
謝謝!
Sonarcloud 只是一個 sonarqube 服務器。
只需使用 聲納掃描儀(可以在此處找到 jenkins 的文檔)。
首先,您需要為 sonar-scanner安裝jenkins 插件。
之后,您使用Manage Jenkins > Configure System
打開聲納掃描儀的Manage Jenkins > Configure System
。
在Server URL
下插入https://sonarcloud.io
並在Server authentication token
下插入您的聲納令牌(sonarclound)
在Manage Jenkins > Configure System
,您應該選中Enable injection of SonarQube server configuration as build environment variables
並在您的作業中的Build Environment
中,您應該啟用Prepare SonarScanner environment
。
完成后,您可以使用$SONAR_MAVEN_GOAL
(如果您使用的是 maven)、./ ./gradlew sonarqube
(如果您使用的是 gradle)或sonar-scanner
(如果您沒有使用這些)來運行sonar-scanner
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.