-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJenkinsfile
216 lines (174 loc) · 7.05 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/usr/bin/env groovy
// This pipeline is designed to run on Esri-internal CI infrastructure.
// -- PIPELINE LIBRARIES
@Library('psl')
import com.esri.zrh.jenkins.PipelineSupportLibrary
import com.esri.zrh.jenkins.PslFactory
import com.esri.zrh.jenkins.psl.UploadTrackingPsl
import com.esri.zrh.jenkins.JenkinsTools
import com.esri.zrh.jenkins.ToolInfo
import com.esri.zrh.jenkins.ce.CityEnginePipelineLibrary
import com.esri.zrh.jenkins.ce.PrtAppPipelineLibrary
import groovy.transform.Field
@Field def psl = PslFactory.create(this, UploadTrackingPsl.ID)
@Field def cepl = new CityEnginePipelineLibrary(this, psl)
@Field def papl = new PrtAppPipelineLibrary(cepl)
// -- SETUP
psl.runsHere('production')
env.PIPELINE_ARCHIVING_ALLOWED = "true"
properties([ disableConcurrentBuilds() ])
// -- GLOBAL DEFINITIONS
@Field final String REPO = '[email protected]:esri/serlio.git'
@Field final String REPO_CREDS = 'jenkins-github-serlio-deployer-key'
@Field final String SOURCES = "serlio.git/src"
@Field final String BUILD_TARGET = 'package'
@Field final String SOURCE_STASH = 'serlio-src'
@Field final List CHECKOUT_CONFIG = [ [ ba: psl.BA_CHECKOUT ] ]
// TODO: abusing grp field to distinguish maya versions per task
@Field final List CONFIGS = [
[ os: cepl.CFG_OS_RHEL7, bc: cepl.CFG_BC_REL, tc: cepl.CFG_TC_GCC93, cc: cepl.CFG_CC_OPT, arch: cepl.CFG_ARCH_X86_64, grp: 'maya2020', maya: PrtAppPipelineLibrary.Dependencies.MAYA2020 ],
[ os: cepl.CFG_OS_RHEL7, bc: cepl.CFG_BC_REL, tc: cepl.CFG_TC_GCC93, cc: cepl.CFG_CC_OPT, arch: cepl.CFG_ARCH_X86_64, grp: 'maya2022', maya: PrtAppPipelineLibrary.Dependencies.MAYA2022 ],
[ os: cepl.CFG_OS_RHEL7, bc: cepl.CFG_BC_REL, tc: cepl.CFG_TC_GCC93, cc: cepl.CFG_CC_OPT, arch: cepl.CFG_ARCH_X86_64, grp: 'maya2023', maya: PrtAppPipelineLibrary.Dependencies.MAYA2023 ],
[ os: cepl.CFG_OS_WIN10, bc: cepl.CFG_BC_REL, tc: cepl.CFG_TC_VC1427, cc: cepl.CFG_CC_OPT, arch: cepl.CFG_ARCH_X86_64, grp: 'maya2020', maya: PrtAppPipelineLibrary.Dependencies.MAYA2020 ],
[ os: cepl.CFG_OS_WIN10, bc: cepl.CFG_BC_REL, tc: cepl.CFG_TC_VC1427, cc: cepl.CFG_CC_OPT, arch: cepl.CFG_ARCH_X86_64, grp: 'maya2022', maya: PrtAppPipelineLibrary.Dependencies.MAYA2022 ],
[ os: cepl.CFG_OS_WIN10, bc: cepl.CFG_BC_REL, tc: cepl.CFG_TC_VC1427, cc: cepl.CFG_CC_OPT, arch: cepl.CFG_ARCH_X86_64, grp: 'maya2023', maya: PrtAppPipelineLibrary.Dependencies.MAYA2023 ],
]
@Field final List TEST_CONFIGS = [
[ os: cepl.CFG_OS_RHEL7, bc: cepl.CFG_BC_REL, tc: cepl.CFG_TC_GCC93, cc: cepl.CFG_CC_OPT, arch: cepl.CFG_ARCH_X86_64, maya: PrtAppPipelineLibrary.Dependencies.MAYA2023 ],
[ os: cepl.CFG_OS_WIN10, bc: cepl.CFG_BC_REL, tc: cepl.CFG_TC_VC1427, cc: cepl.CFG_CC_OPT, arch: cepl.CFG_ARCH_X86_64, maya: PrtAppPipelineLibrary.Dependencies.MAYA2023 ],
]
@Field final List INSTALLER_CONFIG = [ [ os: cepl.CFG_OS_WIN10, bc: cepl.CFG_BC_REL, tc: cepl.CFG_TC_VC1427, cc: cepl.CFG_CC_OPT, arch: cepl.CFG_ARCH_X86_64 ] ]
@Field final List INSTALLER_MAYA_VERS = [ 'maya2020', 'maya2022', 'maya2023' ]
// -- PIPELINE
stage('prepare'){
cepl.runParallel(getCheckoutTask())
}
stage('test') {
cepl.runParallel(getTestTasks())
}
stage('build') {
cepl.runParallel(getBuildTasks())
}
stage('installers') {
cepl.runParallel(getInstallersTasks())
}
papl.finalizeRun('serlio', env.BRANCH_NAME)
// -- TASK GENERATORS
Map getCheckoutTask(){
Map tasks = [:]
tasks << taskGenSerlioSourceCheckout()
return tasks
}
Map getTestTasks() {
Map tasks = [:]
tasks << taskGenSerlioTests()
return tasks
}
Map getBuildTasks() {
Map tasks = [:]
tasks << taskGenSerlio()
return tasks
}
Map getInstallersTasks() {
Map tasks = [:]
tasks << taskGenSerlioInstallers()
return tasks
}
Map taskGenSerlioSourceCheckout() {
return cepl.generateTasks('srl-src', this.&taskSourceCheckout, CHECKOUT_CONFIG)
}
Map taskGenSerlio() {
return cepl.generateTasks('srl-bld', this.&taskBuildSerlio, CONFIGS)
}
Map taskGenSerlioTests() {
return cepl.generateTasks('srl-tst', this.&taskBuildSerlioTests, TEST_CONFIGS)
}
Map taskGenSerlioInstallers() {
return cepl.generateTasks('srl-msi', this.&taskBuildSerlioInstaller, INSTALLER_CONFIG)
}
// -- TASK BUILDERS
def taskSourceCheckout(cfg) {
cepl.cleanCurrentDir()
papl.checkout(REPO, env.BRANCH_NAME, REPO_CREDS)
stash(name: SOURCE_STASH)
}
def taskBuildCMake(cfg, target){
final List deps = [ cfg.maya ]
List defs = [
[ key: 'maya_DIR', val: cfg.maya.p ],
[ key: 'SRL_VERSION_BUILD', val: env.BUILD_NUMBER ]
]
cepl.cleanCurrentDir()
unstash(name: SOURCE_STASH)
deps.each { d -> papl.fetchDependency(d, cfg) }
papl.jpe.dir(path: 'build') {
papl.runCMakeBuild(SOURCES, target, cfg, defs)
}
}
def taskBuildSerlio(cfg) {
final String appName = 'serlio'
taskBuildCMake(cfg, BUILD_TARGET)
def buildProps = papl.jpe.readProperties(file: 'build/deployment.properties')
final String artifactPattern = "${buildProps.package_file}.*"
if(cfg.os == cepl.CFG_OS_WIN10){
dir(path: 'build'){
stashFile = cepl.findOneFile(artifactPattern)
stash(includes: artifactPattern, name: cfg.grp)
stashPath = "${stashFile.path}"
echo("file path to stash: '${stashPath}'")
}
}
final def artifactVersion = { p -> buildProps.package_version_base }
// TODO: abusing grp again to label artifact
def classifierExtractor = { p ->
return cepl.getArchiveClassifier(cfg) + '-' + cfg.grp
}
papl.publish(appName, env.BRANCH_NAME, artifactPattern, artifactVersion, cfg, classifierExtractor)
}
def taskBuildSerlioTests(cfg) {
final String appName = 'serlio-test'
taskBuildCMake(cfg, 'build_and_run_tests')
papl.jpe.junit('build/test/serlio_test_report.xml')
}
def taskBuildSerlioInstaller(cfg) {
final String appName = 'serlio-installer'
cepl.cleanCurrentDir()
unstash(name: SOURCE_STASH)
String antArgs = ""
// fetch outputs from builds
dir(path: 'build'){
dir(path: 'tmp'){
INSTALLER_MAYA_VERS.each { mv ->
unstash(name: mv)
def zipFile = cepl.findOneFile("*${mv}*.zip")
final String zipFileName = zipFile.name
unzip(zipFile: zipFileName)
antArgs += "-D\"${mv}.dir\"=..\\..\\build\\tmp\\${zipFileName.take(zipFileName.lastIndexOf('.'))} "
}
}
}
antArgs += "-D\"serlio.version.build\"=${env.BUILD_NUMBER} "
antArgs += "-D\"build.dir\"=..\\..\\build "
antArgs += "-D\"out.folder\"=out "
antArgs += "-f serlio.git\\deploy"
// Toolchain definition for building MSI installers.
final JenkinsTools compiler = cepl.getToolchainTool(cfg)
final def toolchain = [
new ToolInfo(JenkinsTools.ANT, cfg),
new ToolInfo(JenkinsTools.NINJA, cfg),
new ToolInfo(JenkinsTools.WIX, cfg),
new ToolInfo(compiler, cfg)
]
// Setup environment according to above toolchain definition.
withTool(toolchain) {
psl.runAnt(antArgs)
def buildProps = papl.jpe.readProperties(file: 'build/build_msi/deployment.properties')
final String artifactPattern = "out/${buildProps.package_file}.*"
final def artifactVersion = { p -> buildProps.package_version_base }
// TODO: abusing grp again to label artifact
def classifierExtractor = { p ->
return cepl.getArchiveClassifier(cfg)
}
papl.publish(appName, env.BRANCH_NAME, artifactPattern, artifactVersion, cfg, classifierExtractor)
}
}