forked from Shicheng-Guo/gor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.SonarQubeAnalysis
43 lines (37 loc) · 1.86 KB
/
Jenkinsfile.SonarQubeAnalysis
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!groovy
node {
def buildImage = docker.image('nextcode/builderimg-java:openjdk8')
stage('Pull build image') {
buildImage.pull()
}
stage('SCM Checkout') {
checkout scm
}
def gradleHome = "${WORKSPACE}/.gor_gradle_home"
stage('Prepare build environment') {
sh "mkdir -p ${gradleHome}"
}
def gradleOpts = "-g ${gradleHome} --console=plain"
withCredentials([usernamePassword(credentialsId: 'ArtifactoryBuild', usernameVariable: 'ARTIFACTORY_USER', passwordVariable: 'ARTIFACTORY_PASSWORD'),
string(credentialsId: 'GOR_SONARQUBE_API_KEY', variable: 'SONARQUBE_LOGIN'),]) {
gradleOpts += " -Partifactory_user=${ARTIFACTORY_USER} -Partifactory_password=${ARTIFACTORY_PASSWORD}"
gradleOpts += " -Dsonar.login=${SONARQUBE_LOGIN}"
gradleOpts += " -Dsonar.exclusions=**/*.png,**/*.gif,**/*.GIF,**/*.ttf,**/*.otf,**/*.eot,**/Thumbs.db"
gradleOpts += " -Dsonar.dependencyCheck.xmlReportPath=${WORKSPACE}/build/reports/dependency-check-report.xml"
gradleOpts += " -Dsonar.dependencyCheck.htmlReportPath=${WORKSPACE}/build/reports/dependency-check-report.html"
}
buildImage.inside("--env TZ=UTC --dns 10.3.1.10 --dns 10.3.1.11 --dns-search nextcode.local") {
try {
stage('Analyze') {
sh "./gradlew ${gradleOpts} clean :dependencyCheckAggregate test slowTest integrationTest jacocoTestReport :sonar"
}
} catch (err) {
slackSend channel: 'ra-dev, gor-core', color: 'warning', message: "SonarQube Analysis failed! (<${env.BUILD_URL}|View Failed Job>)", tokenCredentialId: 'SonarQube_Slack_Token'
throw err
} finally {
stage('Publish Test Reports') {
step([$class: 'JUnitResultArchiver', testResults: '**/build/test-results/*/TEST-*.xml'])
}
}
}
}