Skip to content
This repository was archived by the owner on May 31, 2022. It is now read-only.

Commit a5b826f

Browse files
committed
Add Credentials to Sonar Build
1 parent 5841adf commit a5b826f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Jenkinsfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ try {
3333
node {
3434
checkout scm
3535
withCredentials([string(credentialsId: 'spring-sonar.login', variable: 'SONAR_LOGIN')]) {
36-
try {
37-
withEnv(["JAVA_HOME=${ tool 'jdk8' }"]) {
38-
sh "./gradlew clean sonarqube -PexcludeProjects='**/samples/**' -Dsonar.host.url=$SPRING_SONAR_HOST_URL -Dsonar.login=$SONAR_LOGIN --refresh-dependencies --no-daemon"
36+
withCredentials([usernamePassword(credentialsId: '02bd1690-b54f-4c9f-819d-a77cb7a9822c', usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')]) {
37+
try {
38+
withEnv(["JAVA_HOME=${ tool 'jdk8' }"]) {
39+
sh "./gradlew clean sonarqube -PexcludeProjects='**/samples/**' -Dsonar.host.url=$SPRING_SONAR_HOST_URL -Dsonar.login=$SONAR_LOGIN -PartifactoryUsername=$ARTIFACTORY_USERNAME -PartifactoryPassword=$ARTIFACTORY_PASSWORD --refresh-dependencies --no-daemon"
40+
}
41+
} catch(Exception e) {
42+
currentBuild.result = 'FAILED: sonar'
43+
throw e
3944
}
40-
} catch(Exception e) {
41-
currentBuild.result = 'FAILED: sonar'
42-
throw e
4345
}
4446
}
4547
}

0 commit comments

Comments
 (0)