File tree Expand file tree Collapse file tree 3 files changed +40
-38
lines changed
Expand file tree Collapse file tree 3 files changed +40
-38
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -99,6 +99,25 @@ pipeline {
9999 }
100100 }
101101 }
102+ stage (' Analyze' ) {
103+ when {
104+ anyOf {
105+ changeRequest()
106+ branch " main"
107+ }
108+ }
109+ tools {
110+ maven ' maven-3.6.0'
111+ jdk ' jdk11'
112+ }
113+ steps {
114+ withSonarQubeEnv(' SonarCloud' ) {
115+ withCredentials([string(credentialsId : ' encj_github_token' , variable : ' GITHUB_TOKEN' )]) {
116+ runSonarScanner()
117+ }
118+ }
119+ }
120+ }
102121 stage (' Save Nightly Installer' ){
103122 when {
104123 allOf {
@@ -113,4 +132,23 @@ pipeline {
113132 }
114133 }
115134 }
116- }
135+ }
136+
137+ void runSonarScanner () {
138+ def changeUrl = env. GIT_URL . split(" /" )
139+ def org = changeUrl[3 ]
140+ def repo = changeUrl[4 ]. substring(0 , changeUrl[4 ]. length() - 4 )
141+ if (env. CHANGE_ID != null ) {
142+ sh " mvn -B sonar:sonar \
143+ -Dsonar.projectKey=${ org} _${ repo} \
144+ -Dsonar.pullrequest.provider=GitHub \
145+ -Dsonar.pullrequest.github.repository=${ org} /${ repo} \
146+ -Dsonar.pullrequest.key=${ env.CHANGE_ID} \
147+ -Dsonar.pullrequest.branch=${ env.CHANGE_BRANCH} \
148+ -Dsonar.pullrequest.base=${ env.CHANGE_TARGET} "
149+ } else {
150+ sh " mvn -B sonar:sonar \
151+ -Dsonar.projectKey=${ org} _${ repo} \
152+ -Dsonar.branch.name=${ env.BRANCH_NAME} "
153+ }
154+ }
Original file line number Diff line number Diff line change 260260 <plugin >
261261 <groupId >org.jacoco</groupId >
262262 <artifactId >jacoco-maven-plugin</artifactId >
263- <version >0.8.5 </version >
263+ <version >0.8.7 </version >
264264 </plugin >
265265 <plugin >
266266 <groupId >org.sonarsource.scanner.maven</groupId >
You can’t perform that action at this time.
0 commit comments