forked from eclipse-ditto/ditto-clients
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile_multibranch_pipeline
executable file
·95 lines (94 loc) · 3.41 KB
/
Jenkinsfile_multibranch_pipeline
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!groovy
pipeline {
agent none
environment {
// Need to replace the '%2F' used by Jenkins to deal with / in the path (e.g. story/...)
theBranch = "${env.BRANCH_NAME}".replace("%2F", "-").replace("/", "-")
theVersion = "0-${theBranch}-SNAPSHOT"
dittoVersion = "${theVersion}"
theMvnRepo = "$WORKSPACE/../feature-repository-${theBranch}";
JAVA_TOOL_OPTIONS = '-Duser.home=/home/jenkins-slave'
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
disableConcurrentBuilds()
}
stages {
stage('Choose Ditto Version to build against') {
steps {
script {
dittoVersion = askForDittoVersionToUse(dittoVersion)
echo "Selected Ditto version: ${dittoVersion}"
}
}
}
stage('Checkout scm') {
agent {
label "$DITTO_BUILD_NODE"
}
steps {
echo 'Checkout scm'
checkout scm
}
}
stage('Build') {
agent {
docker {
args "$DITTO_DOCKER_ARGS"
image "$DITTO_DOCKER_IMAGE_MAVEN_JDK_8"
}
}
steps {
dir("$WORKSPACE/java") {
configFileProvider([configFile(fileId: 'mvn-bdc-settings', variable: 'MVN_SETTINGS')]) {
sh "mvn -s $MVN_SETTINGS clean deploy javadoc:jar source:jar" +
" --batch-mode --errors" +
" -DcreateJavadoc=true" +
" -Drevision=${theVersion}" +
" -Dditto.version=${dittoVersion}" +
" -Pditto-java-client"
}
}
}
}
stage ('SonarQube') {
agent {
docker {
args "$DITTO_DOCKER_ARGS"
image "$DITTO_DOCKER_IMAGE_MAVEN_JDK_17"
reuseNode true
}
}
when {
expression {
return !params.SKIP_SONAR_SCAN
}
}
steps {
dir("$WORKSPACE/java") {
configFileProvider([configFile(fileId: 'mvn-bdc-settings', variable: 'MVN_SETTINGS')]) {
echo 'Sonar Scan'
withSonarQubeEnv(installationName: "${env.SONAR_QUBE_ENV}", credentialsId: 'sonarqube') {
sh "mvn -s $MVN_SETTINGS --batch-mode --errors $SONAR_MAVEN_GOAL " +
"-Dsonar.host.url=$SONAR_HOST_URL " +
"-Dsonar.projectKey=org.eclipse.ditto:${theBranch} " +
"-Drevision=${theVersion} " +
"-Dditto.version=${dittoVersion} "
}
}
}
}
}
}
}
def askForDittoVersionToUse(defaultVersion) {
try {
timeout(time: 1, unit: 'MINUTES') {
def branch = input message: 'Which Ditto version to use?',
parameters: [string(defaultValue: defaultVersion, description: 'Branch', name: 'DITTO-BRANCH')]
return branch
}
} catch (e) {
return defaultVersion
}
}