-
Notifications
You must be signed in to change notification settings - Fork 407
/
Jenkinsfile.buildchain
195 lines (179 loc) · 8.13 KB
/
Jenkinsfile.buildchain
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
187
188
189
190
191
192
193
194
195
@Library('jenkins-pipeline-shared-libraries')_
agentLabel = "${env.ADDITIONAL_LABEL?.trim() ? ADDITIONAL_LABEL : 'kie-rhel8-pipeline && kie-mem24g && !built-in'}"
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
build_jdk_tool = env.BUILD_JDK_TOOL?.trim() ?: 'kie-jdk11.0.15'
build_maven_tool = env.BUILD_MAVEN_TOOL?.trim() ?: 'kie-maven-3.8.1'
buildChainGroup = env.BUILDCHAIN_GROUP?.trim() ?: '\${GROUP:kiegroup}'
buildChainBranch = env.BUILDCHAIN_BRANCH?.trim() ?: '\${BRANCH:main}'
pipeline {
agent {
label agentLabel
}
tools {
nodejs 'nodejs-16.2.0'
}
options {
timestamps ()
timeout(time: additionalTimeout, unit: 'MINUTES')
}
environment {
FIREFOX_FOLDER = '/opt/tools/firefox-91esr'
}
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('Remove partially downloaded deps') {
steps {
script{
util.rmPartialDeps()
}
}
}
stage('Install build-chain tool') {
steps {
script {
println "[INFO] Getting build-chain version from composite action file"
def buildChainVersion = buildChain.getBuildChainVersionFromCompositeActionFile()
if([null, 'null'].contains(buildChainVersion)) {
def errorMessage = "[ERROR] The build-chain version can't be recovered. Please contact administrator"
println errorMessage
error(errorMessage)
}
println "[INFO] build-chain version recovered '${buildChainVersion}'"
try {
sh "npm install -g @kie/build-chain-action@${buildChainVersion} -registry=${NPM_REGISTRY_URL}"
} catch(e) {
println "[WARNING] Error installing @kie/build-chain-action@${buildChainVersion}. Did you check the version is already published at https://www.npmjs.com/package/@kie/build-chain-action ? In case it is you should wait few minutes for ${NPM_REGISTRY_URL} to be synched up. Otherwise check latest 'Publish' action at https://github.com/kiegroup/github-action-build-chain/actions or contact kiegroup/github-action-build-chain responsible."
println "[INFO] Final @kie/build-chain-action version to be used: ${sh(returnStdout: true, script: 'npm @kie/build-chain-action -v').trim()}"
}
}
}
}
stage('Build projects') {
tools {
jdk build_jdk_tool
maven build_maven_tool
}
steps {
script {
def buildChainActionInfo =
isFDBP() ? [action: 'full_downstream', file: 'downstream-production-config.yaml'] :
isFDB() ? [action: 'full_downstream', file: 'full-downstream-config.yaml'] :
isCompile() ? [action: 'full_downstream', file: 'compilation-config.yaml'] :
[action: 'cross_pr', file: 'pull-request-config.yaml']
def SETTINGS_XML_ID =
isFDBP() ? '5d9884a1-178a-4d67-a3ac-9735d2df2cef' :
'771ff52a-a8b4-40e6-9b22-d54c7314aa1e'
configFileProvider([configFile(fileId: SETTINGS_XML_ID, variable: 'MAVEN_SETTINGS_FILE')]) {
withCredentials([string(credentialsId: 'kie-ci2-token', variable: 'GITHUB_TOKEN')]) {
sh "build-chain build ${buildChainActionInfo.action} --token ${GITHUB_TOKEN} -f 'https://raw.githubusercontent.com/${buildChainGroup}/droolsjbpm-build-bootstrap/${buildChainBranch}/.ci/${buildChainActionInfo.file}' -o bc -u ${env.ghprbPullLink} --skipParallelCheckout -t '(^mvn .*)||\$1 -s ${MAVEN_SETTINGS_FILE} -Dmaven.wagon.http.ssl.insecure=true'"
}
}
}
}
}
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 ...'
recordIssues( enabledForFailure: true, aggregatingResults: true, tool: spotBugs(pattern: findbugsFile) )
}
}
script {
if(checkstyleFile) {
echo 'Checkstyle reports ...'
recordIssues( enabledForFailure: true, aggregatingResults: true, tool: checkStyle(pattern: checkstyleFile) )
}
}
}
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();
}