forked from payara/Payara
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
55 lines (53 loc) · 1.76 KB
/
Jenkinsfile
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
44
45
46
47
48
49
50
51
52
53
54
55
pipeline {
agent none
stages {
stage("Analyse") {
agent {
label "sonar"
}
tools {
jdk "zulu-8"
}
steps {
echo "Analysing"
checkoutAndBuildSource()
}
}
}
}
def checkoutAndBuildSource(){
echo 'JAVA_HOME = ' + JAVA_HOME
prNo = env.BRANCH_NAME
script{
dir('src'){
deleteDir()
}
}
checkout changelog: false,
poll: false,
scm: [$class: 'GitSCM',
branches: [[name: "*/master"]],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'src']],
submoduleCfg: [],
userRemoteConfigs: [[url: 'https://github.com/payara/Payara.git']]]
withCredentials([[$class: 'StringBinding', credentialsId: 'jenkins-held-github-api-token-secret', variable: 'githubToken']
[$class: 'StringBinding', credentialsId: 'jenkins-held-sonarcloud-token-secret', variable: 'sonarToken']]) {
dir('src') {
sh """mvn clean package \
-DskipTests \
-Dsonar.organization=payara \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.pullrequest.provider=github \
-Dsonar.analysis.mode=preview \
-Dsonar.pullrequest.github.repository=payara/Payara \
-Dsonar.pullrequest.github.endpoint=https://api.github.com/ \
-Dsonar.pullrequest.branch=${env.BRANCH_NAME} \
-Dsonar.pullrequest.key=${prNo} \
-Dsonar.pullrequest.base=master \
-Dsonar.github.oauth=${githubToken} \
-Dsonar.login=${sonarToken} \
sonar:sonar"""
}
}
}