Skip to content

Commit 7c3fd2d

Browse files
committed
update cmd sonar
1 parent 9a3c04c commit 7c3fd2d

3 files changed

Lines changed: 18 additions & 14 deletions

File tree

Jenkinsfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ pipeline {
3636

3737
stage('sonarqube analysis') {
3838
steps {
39-
withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) {
40-
withSonarQubeEnv('sonar') {
41-
sh "mvn -o -gs `pwd`/configuration/settings.xml -Dsonar.branch=$BRANCH_NAME -Dsonar.sources=. -Dsonar.login=$SONAR_TOKEN"
39+
container ('maven') {
40+
withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) {
41+
withSonarQubeEnv('sonar') {
42+
sh "mvn sonar:sonar -o -gs `pwd`/configuration/settings.xml -Dsonar.branch=$BRANCH_NAME -Dsonar.sources=. -Dsonar.login=$SONAR_TOKEN"
43+
}
44+
}
45+
timeout(time: 1, unit: 'HOURS') {
46+
waitForQualityGate abortPipeline: true
4247
}
43-
}
44-
timeout(time: 1, unit: 'HOURS') {
45-
waitForQualityGate abortPipeline: true
4648
}
4749
}
4850
}

Jenkinsfile-online

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@ pipeline {
3636

3737
stage('sonarqube analysis') {
3838
steps {
39-
withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) {
40-
withSonarQubeEnv('sonar') {
41-
sh "mvn -gs `pwd`/configuration/settings.xml -Dsonar.branch=$BRANCH_NAME -Dsonar.sources=. -Dsonar.login=$SONAR_TOKEN"
39+
container ('maven') {
40+
withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) {
41+
withSonarQubeEnv('sonar') {
42+
sh "mvn sonar:sonar -o -gs `pwd`/configuration/settings.xml -Dsonar.branch=$BRANCH_NAME -Dsonar.sources=. -Dsonar.login=$SONAR_TOKEN"
43+
}
4244
}
43-
}
44-
timeout(time: 1, unit: 'HOURS') {
45-
waitForQualityGate abortPipeline: true
46-
}
45+
timeout(time: 1, unit: 'HOURS') {
46+
waitForQualityGate abortPipeline: true
47+
}
48+
}
4749
}
4850
}
4951

configuration/settings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<id>sonar</id>
3131
<activation>
3232
<activeByDefault>true</activeByDefault>
33-
</activation>
33+
</activation>
3434
</profile>
3535
</profiles>
3636
<mirrors>

0 commit comments

Comments
 (0)