-
Notifications
You must be signed in to change notification settings - Fork 313
/
Jenkinsfile
130 lines (114 loc) · 4.82 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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
def boolean onlyDocumentationFilesChangedIn(String workDirectory) {
if (!env.CHANGE_TARGET) {
echo "CHANGE_TARGET not set. Skipping check"
return false
}
def changedFiles = sh(script: "cd ${workDirectory} && git diff --name-only origin/${env.CHANGE_TARGET} origin/${env.BRANCH_NAME}", returnStdout: true).trim().split("\n")
echo "Changed files: ${changedFiles}" // Debug
return changedFiles && changedFiles.every { it.endsWith(".md") || it.endsWith(".txt") }
}
node {
properties([
disableConcurrentBuilds(abortPrevious: true),
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '2', daysToKeepStr: '', numToKeepStr: '5')),
gitLabConnection('gitlab.eclipse.org'),
[$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false],
[$class: 'JobLocalConfiguration', changeReasonComment: '']
])
deleteDir()
stage('Preparation') {
dir("kura") {
checkout scm
sh "touch /tmp/isJenkins.txt"
}
}
// Skip build if only documentation files (i.e. *.md and *.txt) have changed
if (onlyDocumentationFilesChangedIn("kura")) {
echo "Skipping build for documentation changes"
currentBuild.result = 'SUCCESS'
return
}
stage('Build target-platform') {
timeout(time: 1, unit: 'HOURS') {
dir("kura") {
withMaven(jdk: 'temurin-jdk17-latest', maven: 'apache-maven-3.9.6') {
sh "mvn -f target-platform/pom.xml clean install -Pno-mirror -Pcheck-exists-plugin"
}
}
}
}
stage('Build core') {
timeout(time: 2, unit: 'HOURS') {
dir("kura") {
withMaven(jdk: 'temurin-jdk17-latest', maven: 'apache-maven-3.9.6') {
sh "mvn -f kura/pom.xml -Dsurefire.rerunFailingTestsCount=3 clean install -Pcheck-exists-plugin"
}
}
}
}
stage('Build distrib') {
timeout(time: 1, unit: 'HOURS') {
dir("kura") {
withMaven(jdk: 'temurin-jdk17-latest', maven: 'apache-maven-3.9.6') {
sh "mvn -f kura/distrib/pom.xml clean install -DbuildAll"
}
}
}
}
stage('Build examples') {
timeout(time: 1, unit: 'HOURS') {
dir("kura") {
withMaven(jdk: 'temurin-jdk17-latest', maven: 'apache-maven-3.9.6') {
sh "mvn -f kura/examples/pom.xml clean install -Pcheck-exists-plugin"
}
}
}
}
stage('Generate test reports') {
dir("kura") {
junit 'kura/test/*/target/surefire-reports/*.xml,kura/examples/test/*/target/surefire-reports/*.xml'
}
}
stage('Archive .deb artifacts') {
dir("kura") {
archiveArtifacts artifacts: 'kura/distrib/target/*.deb', onlyIfSuccessful: true
}
}
stage('Sonar') {
timeout(time: 2, unit: 'HOURS') {
dir("kura") {
withMaven(jdk: 'temurin-jdk17-latest', maven: 'apache-maven-3.9.6') {
withCredentials([string(credentialsId: 'sonarcloud-token', variable: 'SONARCLOUD_TOKEN')]) {
withSonarQubeEnv {
sh '''
mvn -f kura/pom.xml sonar:sonar \
-Dmaven.test.failure.ignore=true \
-Dsonar.organization=eclipse \
-Dsonar.host.url=${SONAR_HOST_URL} \
-Dsonar.token=${SONARCLOUD_TOKEN} \
-Dsonar.branch.name=${BRANCH_NAME} \
-Dsonar.branch.target=${CHANGE_TARGET} \
-Dsonar.java.source=8 \
-Dsonar.java.binaries='target/' \
-Dsonar.core.codeCoveragePlugin=jacoco \
-Dsonar.projectKey=org.eclipse.kura:kura \
-Dsonar.exclusions=test/**/*.java,test-util/**/*.java,org.eclipse.kura.web2/**/*.java,org.eclipse.kura.nm/src/main/java/org/freedesktop/**/*,org.eclipse.kura.nm/src/main/java/fi/w1/**/*
'''
}
}
}
}
}
}
stage('quality-gate') {
// Sonar quality gate
timeout(time: 30, unit: 'MINUTES') {
withCredentials([string(credentialsId: 'sonarcloud-token', variable: 'SONARCLOUD_TOKEN')]) {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to sonar quality gate failure: ${qg.status}"
}
}
}
}
}