forked from kiegroup/droolsjbpm-build-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
186 lines (172 loc) · 7.35 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
@Library('jenkins-pipeline-shared-libraries')_
agentLabel = "${env.ADDITIONAL_LABEL?.trim() ? ADDITIONAL_LABEL : 'kie-rhel7 && kie-mem24g'} && !master"
additionalArtifactsToArchive = "${env.ADDITIONAL_ARTIFACTS_TO_ARCHIVE?.trim() ?: ''}"
additionalTimeout = "${env.ADDITIONAL_TIMEOUT?.trim() ?: 1200}"
additionalExcludedArtifacts = "${env.ADDITIONAL_EXCLUDED_ARTIFACTS?.trim() ?: ''}"
checkstyleFile = env.CHECKSTYLE_FILE?.trim() ?: null
findbugsFile = env.FINDBUGS_FILE?.trim() ?: null
pr_type = env.PR_TYPE?.trim() ?: null
pipeline {
agent {
label agentLabel
}
tools {
maven 'kie-maven-3.6.3'
jdk 'kie-jdk1.8'
}
options {
timestamps ()
timeout(time: additionalTimeout, unit: 'MINUTES')
}
stages {
stage('Initialize') {
steps {
sh 'printenv'
}
}
// executes a script that compresses the consoleText and attaches it to the mail
stage('build sh script') {
steps {
script {
mailer.buildLogScriptPR()
}
}
}
stage('check space before build') {
steps {
script{
util.spaceLeft()
}
}
}
stage('Build projects') {
steps {
script {
def file = isFDBP() ? 'downstream.production.stages' :
isFDB() ? 'fullDownstream.stages' :
isPR() ? 'pullrequest.stages' :
isCompile() ? 'compilation.stages' :
'upstream.stages'
if(fileExists("$WORKSPACE/.ci/${file}")) {
println "File ${file} exists, loading it."
def stage = load("$WORKSPACE/.ci/${file}")
stage("$WORKSPACE/.ci")
} else {
dir("droolsjbpm-build-bootstrap") {
def changeAuthor = env.CHANGE_AUTHOR ?: env.ghprbPullAuthorLogin
def changeBranch = env.CHANGE_BRANCH ?: env.ghprbSourceBranch
def changeTarget = env.CHANGE_TARGET ?: env.ghprbTargetBranch
println "File ${file} does not exist. Loading the one from droolsjbpm-build-bootstrap project. Author [${changeAuthor}], branch [${changeBranch}]..."
githubscm.checkoutIfExists('droolsjbpm-build-bootstrap', "${changeAuthor}", "${changeBranch}", 'kiegroup', "${changeTarget}")
println "Loading ${file} file..."
def stage = load(".ci/${file}")
stage("$WORKSPACE/droolsjbpm-build-bootstrap/.ci")
}
}
}
}
}
stage('Sonar analysis') {
tools {
jdk "kie-jdk11"
}
steps {
script {
if(isPR()) {
def project = util.getProjectTriggeringJob()[1]
if(["optaplanner", "drools", "appformer", "jbpm", "drools-wb", "kie-soup", "droolsjbpm-integration", "kie-wb-common", "openshift-drools-hacep", "optaweb-employee-rostering", "optaweb-vehicle-routing"].contains(project))
{
dir("${env.WORKSPACE}") {
maven.runMavenWithSettingsSonar("771ff52a-a8b4-40e6-9b22-d54c7314aa1e", "-nsu generate-resources -Psonarcloud-analysis -Denforcer.skip=true", "SONARCLOUD_TOKEN", "sonar_analysis.maven.log")
}
} else {
println "Project ${project} shouldn't be analyzed by sonarcloud"
}
} else {
println "[INFO] No sonar analysis execution."
}
}
}
}
stage('check space after build') {
steps {
script{
util.spaceLeft()
}
}
}
}
post {
fixed {
script {
mailer.sendEmail_fixedPR(pr_type)
}
}
aborted {
script {
mailer.sendEmail_abortedPR(pr_type)
}
}
failure {
sh '$WORKSPACE/trace.sh'
script {
mailer.sendEmail_failedPR(pr_type)
}
}
unstable {
script {
mailer.sendEmail_unstablePR(pr_type)
}
}
always {
script {
util.printGitInformationReport()
}
echo 'Generating JUnit report...'
junit allowEmptyResults: true, healthScaleFactor: 1.0, testResults: '**/target/*-reports/TEST-*.xml'
echo 'Archiving logs...'
archiveArtifacts excludes: '**/target/checkstyle.log', artifacts: '**/*.maven.log,**/target/*.log', fingerprint: false, defaultExcludes: true, caseSensitive: true, allowEmptyArchive: true
echo 'Archiving testStatusListener and screenshots artifacts...'
archiveArtifacts allowEmptyArchive: true, artifacts: '**/target/testStatusListener*,**/target/screenshots/**', excludes: additionalExcludedArtifacts, fingerprint: false, defaultExcludes: true, caseSensitive: true
echo 'Archiving wars...'
archiveArtifacts artifacts: '**/target/business-monitoring-webapp.war,**/target/business-central*wildfly*.war,**/target/business-central*eap*.war,**/target/kie-server-*ee7.war,**/target/kie-server-*webc.war,**/target/dashbuilder-runtime.war', fingerprint: false, defaultExcludes: true, caseSensitive: true, allowEmptyArchive: true
echo 'Archiving zips...'
archiveArtifacts artifacts: '**/target/jbpm-server*dist*.zip', fingerprint: false, defaultExcludes: true, caseSensitive: true, allowEmptyArchive: true
script {
if(additionalArtifactsToArchive) {
echo 'Archiving additional Artifacts ...'
archiveArtifacts allowEmptyArchive: true, artifacts: additionalArtifactsToArchive, excludes: additionalExcludedArtifacts, fingerprint: false, defaultExcludes: true, caseSensitive: true
}
}
script {
if(findbugsFile) {
echo 'Findbugs reports ...'
findbugs canComputeNew: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', pattern: findbugsFile, unHealthy: ''
}
}
script {
if(checkstyleFile) {
echo 'Checkstyle reports ...'
checkstyle canComputeNew: false, defaultEncoding: '', healthy: '', pattern: checkstyleFile, unHealthy: ''
}
}
}
cleanup {
script {
util.cleanNode()
}
}
}
}
def isFDBP(){
return (JOB_NAME =~ /\/[a-z,A-Z\-\_0-9\.]*\.fdbp/).find();
}
def isFDB(){
return (JOB_NAME =~ /\/[a-z,A-Z\-\_0-9\.]*\.fdb/).find();
}
def isPR(){
return (JOB_NAME =~ /\/[a-z,A-Z\-\_0-9\.]*\.pr/).find();
}
def isCompile(){
return (JOB_NAME =~ /\/[a-z,A-Z\-\_0-9\.]*\.compile/).find();
}