forked from infosia/titanium_mobile_windows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
212 lines (198 loc) · 6.89 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
#!groovy
def gitCommit = ''
def build(sdkVersion, msBuildVersion, architecture, gitCommit) {
unstash 'sources' // for build
if (fileExists('dist/windows')) {
bat 'rmdir dist\\windows /Q /S'
}
bat 'mkdir dist\\windows'
dir('Tools/Scripts') {
bat 'npm install .'
echo "Installing JSC built for Windows ${sdkVersion}"
bat "node setup.js -s ${sdkVersion} --no-color --no-progress-bars"
bat 'rmdir node_modules /Q /S'
}
dir('Tools/Scripts/build') {
bat 'npm install .'
timeout(45) {
echo "Building for ${architecture} ${sdkVersion}"
def raw = bat(returnStdout: true, script: "echo %JavaScriptCore_${sdkVersion}_HOME%").trim()
def jscHome = raw.split('\n')[-1]
echo "Setting JavaScriptCore_HOME to ${jscHome}"
withEnv(["JavaScriptCore_HOME=${jscHome}"]) {
bat "node build.js -s ${sdkVersion} -m ${msBuildVersion} -o ${architecture} --sha ${gitCommit}"
}
}
}
archiveArtifacts artifacts: 'dist/**/*'
}
// wrap in timestamps
timestamps {
// Generate docs on generic node
stage('Docs') {
node('npm && node') {
try {
// checkout scm
// Hack for JENKINS-37658 - see https://support.cloudbees.com/hc/en-us/articles/226122247-How-to-Customize-Checkout-for-Pipeline-Multibranch
checkout([
$class: 'GitSCM',
branches: scm.branches,
extensions: scm.extensions + [
[$class: 'CleanCheckout'],
[$class: 'SubmoduleOption', disableSubmodules: false, parentCredentials: true, recursiveSubmodules: true, reference: '', trackingSubmodules: false],
[$class: 'CloneOption', depth: 30, honorRefspec: true, noTags: true, reference: '', shallow: true]
],
userRemoteConfigs: scm.userRemoteConfigs
])
// FIXME: Workaround for missing env.GIT_COMMIT: http://stackoverflow.com/questions/36304208/jenkins-workflow-checkout-accessing-branch-name-and-git-commit
gitCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
// Stash our source code/scripts so we don't need to checkout again?
stash name: 'sources', includes: '**', excludes: 'apidoc/**,test/**,Examples/**'
stash name: 'NMocha', includes: 'Examples/NMocha/**/*'
if (isUnix()) {
sh 'mkdir -p dist/windows/doc'
} else {
bat 'mkdir dist\\\\windows\\\\doc'
}
echo 'Generating docs'
dir('apidoc') {
if (isUnix()) {
sh 'npm install .'
sh 'node ti_win_yaml.js'
} else {
bat 'call npm install .'
bat 'call node ti_win_yaml.js'
}
}
echo 'copying generated docs to dist folder'
if (isUnix()) {
sh 'mv apidoc/Titanium dist/windows/doc/Titanium'
} else {
bat '(robocopy apidoc\\\\Titanium dist\\\\windows\\\\doc\\\\Titanium /e) ^& IF %ERRORLEVEL% LEQ 3 cmd /c exit 0'
}
archiveArtifacts artifacts: 'dist/**/*'
} catch (e) {
// if any exception occurs, mark the build as failed
currentBuild.result = 'FAILURE'
throw e
} finally {
step([$class: 'WsCleanup', notFailBuild: true])
}
}
}
stage ('Build') {
def targetBranch = 'master'
if (!env.BRANCH_NAME.startsWith('PR-')) {
targetBranch = env.BRANCH_NAME
}
parallel(
'Windows 8.1 Store x86': {
node('msbuild-12 && (vs2013 || vs2015) && hyper-v && windows-sdk-8.1 && npm && node && cmake && jsc') {
try {
build('8.1', '12.0', 'WindowsStore-x86', gitCommit)
unstash 'NMocha' // for tests
dir('Tools/Scripts/build') {
timeout(10) {
echo 'Running Tests on Windows 8.1 Desktop'
bat "node test.js -s 8.1 -T ws-local -p Windows8_1.Store -b ${targetBranch}"
}
// Kill the desktop app, so workspace cleanup works...
bat 'taskkill /IM Mocha.exe /F'
}
junit 'dist/junit_report.xml'
step([$class: 'WsCleanup', notFailBuild: true])
} catch (e) {
// if any exception occurs, mark the build as failed
currentBuild.result = 'FAILURE'
throw e
}
}
},
'Windows 8.1 Phone x86': {
node('msbuild-12 && (vs2013 || vs2015) && hyper-v && windows-sdk-8.1 && npm && node && cmake && jsc') {
try {
build('8.1', '12.0', 'WindowsPhone-x86', gitCommit)
unstash 'NMocha' // for tests
dir('Tools/Scripts/build') {
timeout(10) {
echo 'Running Tests on Windows 8.1 Phone Emulator'
bat "node test.js -s 8.1 -T wp-emulator -p Windows8_1.Phone -b ${targetBranch}"
}
// Kill the phone emulator, so workspace cleanup works...
bat 'taskkill /IM xde.exe'
}
junit 'dist/junit_report.xml'
step([$class: 'WsCleanup', notFailBuild: true])
} catch (e) {
// if any exception occurs, mark the build as failed
currentBuild.result = 'FAILURE'
throw e
}
}
},
'Windows 8.1 Phone ARM': {
node('msbuild-12 && (vs2013 || vs2015) && windows-sdk-8.1 && npm && node && cmake && jsc') {
try {
build('8.1', '12.0', 'WindowsPhone-ARM', gitCommit)
step([$class: 'WsCleanup', notFailBuild: true])
} catch (e) {
// if any exception occurs, mark the build as failed
currentBuild.result = 'FAILURE'
throw e
}
}
},
'Windows 10 x86': {
node('msbuild-14 && vs2015 && hyper-v && windows-sdk-10 && npm && node && cmake && jsc') {
try {
build('10.0', '14.0', 'WindowsStore-x86', gitCommit)
unstash 'NMocha' // for tests
dir('Tools/Scripts/build') {
timeout(10) {
echo 'Running Tests on Windows 10 Desktop'
bat "node test.js -s 10.0 -T ws-local -p Windows10.Store -b ${targetBranch}"
}
// Kill the desktop app, so workspace cleanup works...
bat 'taskkill /IM Mocha.exe /F'
}
junit 'dist/junit_report.xml'
// Delete the report from store, so if phone fails we don't pick this one up
bat 'del /f /q dist\\junit_report.xml'
dir('Tools/Scripts/build') {
timeout(10) {
echo 'Running Tests on Windows 10 Phone Emulator'
bat "node test.js -s 10.0.10586 -T wp-emulator -p Windows10.Phone -b ${targetBranch}"
}
// Kill the phone emulator, so workspace cleanup works...
bat 'taskkill /IM xde.exe'
}
junit 'dist/junit_report.xml'
step([$class: 'WsCleanup', notFailBuild: true])
} catch (e) {
// if any exception occurs, mark the build as failed
currentBuild.result = 'FAILURE'
throw e
}
}
},
'Windows 10 ARM': {
node('msbuild-14 && vs2015 && hyper-v && windows-sdk-10 && npm && node && cmake && jsc') {
try {
build('10.0', '14.0', 'WindowsStore-ARM', gitCommit)
step([$class: 'WsCleanup', notFailBuild: true])
} catch (e) {
// if any exception occurs, mark the build as failed
currentBuild.result = 'FAILURE'
throw e
}
}
},
failFast: true
)
}
// If not a PR, trigger titanium_mobile to build
if (!env.BRANCH_NAME.startsWith('PR-')) {
// Trigger build of titaium_mobile in our pipeline multibranch group!
build job: "appcelerator/titanium_mobile/${env.BRANCH_NAME}", wait: false
}
}