Skip to content

Commit

Permalink
Improved formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
asolimando committed Jul 26, 2024
1 parent 88e7e27 commit 5165fab
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,27 @@ node('ubuntu') {
withEnv(["Path+JDK=$JAVA_JDK_17/bin","JAVA_HOME=$JAVA_JDK_17"]) {
withCredentials([string(credentialsId: 'SONARCLOUD_TOKEN', variable: 'SONAR_TOKEN')]) {
def JVM_ARGS = "-XX:+UseG1GC -Xmx1536m -XX:MaxMetaspaceSize=512m"
def COMMON_ARGS = "build --no-parallel --no-daemon jacocoAggregateTestReport sonar -PenableJacoco -Porg.sonarqube.version=4.4.1.3373 -Dsonar.token=${SONAR_TOKEN} -Dorg.gradle.jvmargs='${JVM_ARGS}' "
// SONAR_TOKEN is a secret and can't be interpolated in a Groovy string for security measures,
// see https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#interpolation-of-sensitive-environment-variables
def COMMON_ARGS = """
build --no-parallel --no-daemon jacocoAggregateTestReport \
sonar -PenableJacoco -Porg.sonarqube.version=4.4.1.3373 \
-Dorg.gradle.jvmargs='${JVM_ARGS}'
"""

if (env.BRANCH_NAME.startsWith("PR-")) {
def PR_ARGS = "-Dsonar.pullrequest.branch=${CHANGE_BRANCH} -Dsonar.pullrequest.base=${CHANGE_TARGET} -Dsonar.pullrequest.key=${CHANGE_ID}"
sh "./gradlew ${COMMON_ARGS} ${PR_ARGS}"
def PR_ARGS = """
-Dsonar.pullrequest.branch=${CHANGE_BRANCH} \
-Dsonar.pullrequest.base=${CHANGE_TARGET} \
-Dsonar.pullrequest.key=${CHANGE_ID}
"""
sh "./gradlew ${COMMON_ARGS} ${PR_ARGS} -Dsonar.token=${SONAR_TOKEN}"
} else {
def BRANCH_ARGS = "-Dsonar.branch.name=${BRANCH_NAME}"
sh "./gradlew ${COMMON_ARGS} ${BRANCH_ARGS}"
sh "./gradlew ${COMMON_ARGS} -Dsonar.branch.name=${BRANCH_NAME} -Dsonar.token=${SONAR_TOKEN}"
}
}
}
}
}
cleanWs()
}

0 comments on commit 5165fab

Please sign in to comment.