Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d87e8bed25f5e9b97f8ed4e92f8a91438fe2bd48 (plain) (blame)
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
#!/bin/bash -x

#--------------------------------------------------------------------------------
# Copyright (c) 2012 CEA LIST.
#
#    
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
#    Nicolas Bros (Mia-Software)
#--------------------------------------------------------------------------------

# This script compares the date of a signal file touched by the hudson build
# with the date of a reference file touched at the end of each promote.
# It then promotes the result of the build. The promote is not done from
# Hudson because it does not have the necessary rights.

# exit on error
set -o errexit
# error when using an unset variable
set -o nounset

### TRUNK ###

LAST_PROMOTE_FILE_TRUNK_NIGHTLY=/opt/public/modeling/mdt/papyrus/papyrus-trunk-nightly/lastPromoteRef
PROMOTE_SIGNAL_TRUNK_NIGHTLY=/opt/public/modeling/mdt/papyrus/papyrus-trunk-nightly/promoteSignal
PROMOTE_VERSION_TRUNK_NIGHTLY=/opt/public/modeling/mdt/papyrus/papyrus-trunk-nightly/promoteVersion

LAST_PROMOTE_FILE_TRUNK_EXTRA_NIGHTLY=/opt/public/modeling/mdt/papyrus/papyrus-trunk-extra-nightly/lastPromoteRef
PROMOTE_SIGNAL_TRUNK_EXTRA_NIGHTLY=/opt/public/modeling/mdt/papyrus/papyrus-trunk-extra-nightly/promoteSignal
PROMOTE_VERSION_TRUNK_EXTRA_NIGHTLY=/opt/public/modeling/mdt/papyrus/papyrus-trunk-extra-nightly/promoteVersion

LAST_PROMOTE_FILE_TRUNK_NIGHTLY_TESTS=/opt/public/modeling/mdt/papyrus/papyrus-trunk-nightly-tests/lastPromoteRef
PROMOTE_SIGNAL_TRUNK_NIGHTLY_TESTS=/opt/public/modeling/mdt/papyrus/papyrus-trunk-nightly-tests/promoteSignal
PROMOTE_VERSION_TRUNK_NIGHTLY_TESTS=/opt/public/modeling/mdt/papyrus/papyrus-trunk-nightly-tests/promoteVersion

### MAINTENANCE 0.10 ###

LAST_PROMOTE_FILE_0_10_MAINTENANCE_NIGHTLY=/opt/public/modeling/mdt/papyrus/papyrus-0.10-maintenance-nightly/lastPromoteRef
PROMOTE_SIGNAL_0_10_MAINTENANCE_NIGHTLY=/opt/public/modeling/mdt/papyrus/papyrus-0.10-maintenance-nightly/promoteSignal
PROMOTE_VERSION_0_10_MAINTENANCE_NIGHTLY=/opt/public/modeling/mdt/papyrus/papyrus-0.10-maintenance-nightly/promoteVersion

LAST_PROMOTE_FILE_0_10_MAINTENANCE_EXTRA_NIGHTLY=/opt/public/modeling/mdt/papyrus/papyrus-0.10-maintenance-extra-nightly/lastPromoteRef
PROMOTE_SIGNAL_0_10_MAINTENANCE_EXTRA_NIGHTLY=/opt/public/modeling/mdt/papyrus/papyrus-0.10-maintenance-extra-nightly/promoteSignal
PROMOTE_VERSION_0_10_MAINTENANCE_EXTRA_NIGHTLY=/opt/public/modeling/mdt/papyrus/papyrus-0.10-maintenance-extra-nightly/promoteVersion

LAST_PROMOTE_FILE_0_10_MAINTENANCE_NIGHTLY_TESTS=/opt/public/modeling/mdt/papyrus/papyrus-0.10-maintenance-nightly-tests/lastPromoteRef
PROMOTE_SIGNAL_0_10_MAINTENANCE_NIGHTLY_TESTS=/opt/public/modeling/mdt/papyrus/papyrus-0.10-maintenance-nightly-tests/promoteSignal
PROMOTE_VERSION_0_10_MAINTENANCE_NIGHTLY_TESTS=/opt/public/modeling/mdt/papyrus/papyrus-0.10-maintenance-nightly-tests/promoteVersion

### Update Sites ###

UPDATES_TRUNK_NIGHTLY=/home/data/httpd/download.eclipse.org/modeling/mdt/papyrus/updates/nightly/luna/main
UPDATES_TRUNK_EXTRA_NIGHTLY=/home/data/httpd/download.eclipse.org/modeling/mdt/papyrus/updates/nightly/luna/extra
UPDATES_0_10_MAINTENANCE_NIGHTLY=/home/data/httpd/download.eclipse.org/modeling/mdt/papyrus/updates/nightly/kepler/main
UPDATES_0_10_MAINTENANCE_EXTRA_NIGHTLY=/home/data/httpd/download.eclipse.org/modeling/mdt/papyrus/updates/nightly/kepler/extra

DROPS_DIR=/home/data/httpd/download.eclipse.org/modeling/mdt/papyrus/downloads/drops

ARCHIVE_DIR=/home/data/httpd/archive.eclipse.org/modeling/mdt/papyrus/downloads/drops
ARCHIVE_INDEX=/home/data/httpd/archive.eclipse.org/modeling/mdt/papyrus/downloads/index.html

# constants required by promoteFunctions.sh
# export ADD_DOWNLOAD_STATS=/opt/public/modeling/mdt/papyrus/addDownloadStats.sh

# wait for up to 15 minutes for Hudson to finish (archive the result)
JOB_FINISH_WAIT_TIMEOUT=900

# include promote functions
source $(dirname $0)/promoteFunctions.sh

DATE=$(date +%Y%m%d-%H%M)

echo "[$DATE] starting cronPromote.sh --------------------------------------------------"

### TRUNK ###

if [ ! -e $LAST_PROMOTE_FILE_TRUNK_NIGHTLY ]; then touch $LAST_PROMOTE_FILE_TRUNK_NIGHTLY; fi
if [ ! -e $LAST_PROMOTE_FILE_TRUNK_EXTRA_NIGHTLY ]; then touch $LAST_PROMOTE_FILE_TRUNK_EXTRA_NIGHTLY; fi
if [ ! -e $LAST_PROMOTE_FILE_TRUNK_NIGHTLY_TESTS ]; then touch $LAST_PROMOTE_FILE_TRUNK_NIGHTLY_TESTS; fi

### MAINTENANCE 0.10 ###

if [ ! -e $LAST_PROMOTE_FILE_0_10_MAINTENANCE_NIGHTLY ]; then touch $LAST_PROMOTE_FILE_0_10_MAINTENANCE_NIGHTLY; fi
if [ ! -e $LAST_PROMOTE_FILE_0_10_MAINTENANCE_EXTRA_NIGHTLY ]; then touch $LAST_PROMOTE_FILE_0_10_MAINTENANCE_EXTRA_NIGHTLY; fi
if [ ! -e $LAST_PROMOTE_FILE_0_10_MAINTENANCE_NIGHTLY_TESTS ]; then touch $LAST_PROMOTE_FILE_0_10_MAINTENANCE_NIGHTLY_TESTS; fi

###

if [ ! -e $PROMOTE_SIGNAL_TRUNK_NIGHTLY ]; then echo "$DATE: ERROR: $PROMOTE_SIGNAL_TRUNK_NIGHTLY not found"; exit 1; fi
if [ ! -e $PROMOTE_SIGNAL_TRUNK_EXTRA_NIGHTLY ]; then echo "$DATE: ERROR: $PROMOTE_SIGNAL_TRUNK_EXTRA_NIGHTLY not found"; exit 1; fi
if [ ! -e $PROMOTE_SIGNAL_TRUNK_NIGHTLY_TESTS ]; then echo "$DATE: ERROR: $PROMOTE_SIGNAL_TRUNK_NIGHTLY_TESTS not found"; exit 1; fi

if [ ! -e $PROMOTE_SIGNAL_0_10_MAINTENANCE_NIGHTLY ]; then echo "$DATE: ERROR: $PROMOTE_SIGNAL_0_10_MAINTENANCE_NIGHTLY not found"; exit 1; fi
if [ ! -e $PROMOTE_SIGNAL_0_10_MAINTENANCE_EXTRA_NIGHTLY ]; then echo "$DATE: ERROR: $PROMOTE_SIGNAL_0_10_MAINTENANCE_EXTRA_NIGHTLY not found"; exit 1; fi
if [ ! -e $PROMOTE_SIGNAL_0_10_MAINTENANCE_NIGHTLY_TESTS ]; then echo "$DATE: ERROR: $PROMOTE_SIGNAL_0_10_MAINTENANCE_NIGHTLY_TESTS not found"; exit 1; fi

###

signalDateTrunkNightly=$(stat --format=%Y $PROMOTE_SIGNAL_TRUNK_NIGHTLY)
signalDateTrunkExtraNightly=$(stat --format=%Y $PROMOTE_SIGNAL_TRUNK_EXTRA_NIGHTLY)
signalDateTrunkNightlyTests=$(stat --format=%Y $PROMOTE_SIGNAL_TRUNK_NIGHTLY_TESTS)

signalDate10MaintenanceNightly=$(stat --format=%Y $PROMOTE_SIGNAL_0_10_MAINTENANCE_NIGHTLY)
signalDate10MaintenanceExtraNightly=$(stat --format=%Y $PROMOTE_SIGNAL_0_10_MAINTENANCE_EXTRA_NIGHTLY)
signalDate10MaintenanceNightlyTests=$(stat --format=%Y $PROMOTE_SIGNAL_0_10_MAINTENANCE_NIGHTLY_TESTS)

###

lastPromoteDateTrunkNightly=$(stat --format=%Y $LAST_PROMOTE_FILE_TRUNK_NIGHTLY)
lastPromoteDateTrunkExtraNightly=$(stat --format=%Y $LAST_PROMOTE_FILE_TRUNK_EXTRA_NIGHTLY)
lastPromoteDateTrunkNightlyTests=$(stat --format=%Y $LAST_PROMOTE_FILE_TRUNK_NIGHTLY_TESTS)

lastPromoteDate10MaintenanceNightly=$(stat --format=%Y $LAST_PROMOTE_FILE_0_10_MAINTENANCE_NIGHTLY)
lastPromoteDate10MaintenanceExtraNightly=$(stat --format=%Y $LAST_PROMOTE_FILE_0_10_MAINTENANCE_EXTRA_NIGHTLY)
lastPromoteDate10MaintenanceNightlyTests=$(stat --format=%Y $LAST_PROMOTE_FILE_0_10_MAINTENANCE_NIGHTLY_TESTS)

########## trunk main nightly ##########
if [ $signalDateTrunkNightly -gt $lastPromoteDateTrunkNightly ]; then
	# mark the promote as done
	touch "$LAST_PROMOTE_FILE_TRUNK_NIGHTLY"
	
	waitUntilJobIsFinished "papyrus-trunk-nightly" "$JOB_FINISH_WAIT_TIMEOUT"
	
	# the Hudson job wrote these build name and version to publish
	buildName=$(cat "$PROMOTE_SIGNAL_TRUNK_NIGHTLY")
	version=$(cat "$PROMOTE_VERSION_TRUNK_NIGHTLY")
	zipName="Papyrus-Main.zip"
	
	echo "[$DATE] deleting previous nightly update site"
	rm -rf "$UPDATES_TRUNK_NIGHTLY"
	
	buildsDir="$DROPS_DIR/$version"
	echo "[$DATE] pruning old builds"
	prune N "$buildsDir" 2

	nfsURL="/shared/jobs/papyrus-trunk-nightly/lastSuccessful/archive/"
	hudsonURL="https://hudson.eclipse.org/hudson/job/papyrus-trunk-nightly/lastSuccessfulBuild/artifact/"
	export SVN_DIRECTORIES_TO_TAG=( )
	promote "$zipName" "$version" "$nfsURL" "$hudsonURL" "$DROPS_DIR" "$ARCHIVE_DIR" "$ARCHIVE_INDEX" "$UPDATES_TRUNK_NIGHTLY" "Papyrus-Update-" "NA"

	echo "[$DATE] promote done"
	
	# trigger the tests and extras builds by using the Hudson Rest API
	# see http://wiki.hudson-ci.org/display/HUDSON/Remote+access+API
	
	echo "[$DATE] triggering Hudson tests build"
	json='{"parameter": [
		{"name": "BUCKMINSTER_LOGLEVEL", "value": "DEBUG"},
		{"name": "CLEAN_TP", "value": "true"},
		{"name": "CLEAN_WORKSPACE", "value": "true"},
		{"name": "CLEAN_OUTPUT", "value": "true"},
		{"name": "CLEAN_TOOLS", "value": "false"},
		{"name": "BUILD_TARGET", "value": "test"},
		{"name": "BUILD_TYPE", "value": "N"}
	], "": ""}'
	curl -X POST https://hudson.eclipse.org/hudson/job/papyrus-trunk-nightly-tests/build -d token=token --data-urlencode json="$json" | grep --ignore-case error && exit -1

	echo "[$DATE] triggering Hudson extras build"
	json='{"parameter": [
		{"name": "BUCKMINSTER_LOGLEVEL", "value": "DEBUG"},
		{"name": "CLEAN_TP", "value": "true"},
		{"name": "CLEAN_WORKSPACE", "value": "true"},
		{"name": "CLEAN_OUTPUT", "value": "true"},
		{"name": "CLEAN_TOOLS", "value": "false"},
		{"name": "BUILD_TYPE", "value": "N"},
		{"name": "SITE_PACK200", "value": "true"},
		{"name": "BUILD_TARGET", "value": "site.p2"},
		{"name": "JAVA_HOME", "value": "/shared/common/sun-jdk1.6.0_21_x64"},
		{"name": "SIGN_UPDATE_SITE", "value": "false"}
	], "": ""}'
	curl -X POST https://hudson.eclipse.org/hudson/job/papyrus-trunk-extra-nightly/build -d token=token --data-urlencode json="$json" | grep --ignore-case error && exit -1
fi

########## trunk main nightly tests ##########
if [ $signalDateTrunkNightlyTests -gt $lastPromoteDateTrunkNightlyTests ]; then
	# mark the promote as done
	touch "$LAST_PROMOTE_FILE_TRUNK_NIGHTLY_TESTS"

	waitUntilJobIsFinished "papyrus-trunk-nightly-tests" "$JOB_FINISH_WAIT_TIMEOUT"

	dirBefore=$(pwd)
	echo "[$DATE] creating working dir"
	workingDir=$(mktemp -d)
	cd "$workingDir"

	# for the tests build, the build name and version are taken from the last main build since the artifacts 
	# must go to the same folder, and we want to be able to start several extra jobs after one single main job

	buildName=$(cat "$PROMOTE_SIGNAL_TRUNK_NIGHTLY")
	version=$(cat "$PROMOTE_VERSION_TRUNK_NIGHTLY")
	zipName="Papyrus-TestResults.zip"
	nfsURL="/shared/jobs/papyrus-trunk-nightly-tests/lastSuccessful/archive/"
	hudsonURL="https://hudson.eclipse.org/hudson/job/papyrus-trunk-nightly-tests/lastSuccessfulBuild/artifact/"

	cp "$nfsURL/${zipName}" . || wget --no-check-certificate "$hudsonURL/${zipName}"
	if [ ! -f "$zipName" ]; then echo "ERROR: $zipName (from Hudson) not found"; exit -2; fi
	echo "[$DATE] Testing zip integrity"
	unzip -t "$zipName"
	buildsDir="$DROPS_DIR/$version/$buildName"
	echo "[$DATE] publishing build (version='$version') to the builds directory '$buildsDir'..."
	unzip -o "$zipName" -d "$buildsDir"
	echo "[$DATE] setting access rights"
	setAccessRights "$buildsDir"

	echo "[$DATE] promote done"

	cd ${dirBefore}
	echo "[$DATE] deleting working dir"
	rm -rf "$workingDir"
	
	# TODO: re-enable when the job is implemented
	# echo "[$DATE] triggering Hudson tests build"
	# curl https://hudson.eclipse.org/hudson/job/papyrus-trunk-extra-nightly-tests/buildWithParameters?token=token
fi

########## trunk extras nightly ##########
if [ $signalDateTrunkExtraNightly -gt $lastPromoteDateTrunkExtraNightly ]; then
	# mark the promote as done
	touch "$LAST_PROMOTE_FILE_TRUNK_EXTRA_NIGHTLY"
	
	waitUntilJobIsFinished "papyrus-trunk-extra-nightly" "$JOB_FINISH_WAIT_TIMEOUT"

	dirBefore=$(pwd)
	echo "[$DATE] creating working dir"
	workingDir=$(mktemp -d)
	cd "$workingDir"
	
	# for the extra build, the build name and version are taken from the last main build since the artifacts 
	# must go to the same folder, and we want to be able to start several extra jobs after one single main job
	
	buildName=$(cat "$PROMOTE_SIGNAL_TRUNK_NIGHTLY")
	version=$(cat "$PROMOTE_VERSION_TRUNK_NIGHTLY")
	zipName="Papyrus-Extra.zip"
	updateZipName="Papyrus-Extra-Update.zip"
	nfsURL="/shared/jobs/papyrus-trunk-extra-nightly/lastSuccessful/archive/"
	hudsonURL="https://hudson.eclipse.org/hudson/job/papyrus-trunk-extra-nightly/lastSuccessfulBuild/artifact/"
	
	# publish to existing drops folder
	cp "$nfsURL/${zipName}" . || wget --no-check-certificate "$hudsonURL/${zipName}"
	if [ ! -f "$zipName" ]; then echo "ERROR: $zipName (from Hudson) not found"; exit -2; fi
	echo "[$DATE] Testing zip integrity"
	unzip -t "$zipName"
	buildsDir="$DROPS_DIR/$version/$buildName"
	echo "[$DATE] publishing build (version='$version') to the builds directory '$buildsDir'..."
	unzip -o "$zipName" -d "$buildsDir"

	# publish to composite update site
	tmpDrop=$(mktemp -d)
	unzip "$zipName" -d "$tmpDrop"
	dirNameInZip=$(ls -1 "$tmpDrop")
	[ $(echo "$dirNameInZip" | wc -l) == 1 ] || { echo "one directory expected in zip"; exit 1; }
	rm -rf "$UPDATES_TRUNK_EXTRA_NIGHTLY"
	unzip -o "$tmpDrop/$dirNameInZip/${updateZipName}" -d "$UPDATES_TRUNK_EXTRA_NIGHTLY"
	
	echo "[$DATE] setting access rights"
	setAccessRights "$buildsDir"
	setAccessRights "$UPDATES_TRUNK_EXTRA_NIGHTLY"
	
	echo "[$DATE] promote done"
	
	cd ${dirBefore}
	echo "[$DATE] deleting working dir"
	rm -rf "$workingDir"
	rm -rf "$tmpDrop"
	
	# trigger the extras tests build by using the Hudson Rest API
	# see http://wiki.hudson-ci.org/display/HUDSON/Remote+access+API
	
	echo "[$DATE] triggering Hudson extras tests build"
	json='{"parameter": [
		{"name": "BUCKMINSTER_LOGLEVEL", "value": "DEBUG"},
		{"name": "CLEAN_TP", "value": "true"},
		{"name": "CLEAN_WORKSPACE", "value": "true"},
		{"name": "CLEAN_OUTPUT", "value": "true"},
		{"name": "CLEAN_TOOLS", "value": "false"},
		{"name": "BUILD_TYPE", "value": "N"},
		{"name": "BUILD_TARGET", "value": "test"}
	], "": ""}'
	curl -X POST https://hudson.eclipse.org/hudson/job/papyrus-trunk-extra-nightly-tests/build -d token=token --data-urlencode json="$json" | grep --ignore-case error && exit -1
fi

########## maintenance main 0.10 nightly ##########
if [ $signalDate10MaintenanceNightly -gt $lastPromoteDate10MaintenanceNightly ]; then
	# mark the promote as done
	touch "$LAST_PROMOTE_FILE_0_10_MAINTENANCE_NIGHTLY"
	
	waitUntilJobIsFinished "papyrus-0.10-maintenance-nightly" "$JOB_FINISH_WAIT_TIMEOUT"
	
	# the Hudson job wrote these build name and version to publish
	buildName=$(cat "$PROMOTE_SIGNAL_0_10_MAINTENANCE_NIGHTLY")
	version=$(cat "$PROMOTE_VERSION_0_10_MAINTENANCE_NIGHTLY")
	zipName="Papyrus-Main.zip"
	
	echo "[$DATE] deleting previous nightly update site"
	rm -rf "$UPDATES_0_10_MAINTENANCE_NIGHTLY"
	
	buildsDir="$DROPS_DIR/$version"
	echo "[$DATE] pruning old builds"
	prune N "$buildsDir" 2

	nfsURL="/shared/jobs/papyrus-0.10-maintenance-nightly/lastSuccessful/archive/"
	hudsonURL="https://hudson.eclipse.org/hudson/job/papyrus-0.10-maintenance-nightly/lastSuccessfulBuild/artifact/"
	export SVN_DIRECTORIES_TO_TAG=( )
	promote "$zipName" "$version" "$nfsURL" "$hudsonURL" "$DROPS_DIR" "$ARCHIVE_DIR" "$ARCHIVE_INDEX" "$UPDATES_0_10_MAINTENANCE_NIGHTLY" "Papyrus-Update-" "NA"

	echo "[$DATE] promote done"
	
	# trigger the tests and extras builds by using the Hudson Rest API
	# see http://wiki.hudson-ci.org/display/HUDSON/Remote+access+API
	
	echo "[$DATE] triggering Hudson tests build"
	json='{"parameter": [
		{"name": "BUCKMINSTER_LOGLEVEL", "value": "DEBUG"},
		{"name": "CLEAN_TP", "value": "true"},
		{"name": "CLEAN_WORKSPACE", "value": "true"},
		{"name": "CLEAN_OUTPUT", "value": "true"},
		{"name": "CLEAN_TOOLS", "value": "false"},
		{"name": "BUILD_TARGET", "value": "test"},
		{"name": "BUILD_TYPE", "value": "N"}
	], "": ""}'
	curl -X POST https://hudson.eclipse.org/hudson/job/papyrus-0.10-maintenance-nightly-tests/build -d token=token --data-urlencode json="$json" | grep --ignore-case error && exit -1

	echo "[$DATE] triggering Hudson extras build"
	json='{"parameter": [
		{"name": "BUCKMINSTER_LOGLEVEL", "value": "DEBUG"},
		{"name": "CLEAN_TP", "value": "true"},
		{"name": "CLEAN_WORKSPACE", "value": "true"},
		{"name": "CLEAN_OUTPUT", "value": "true"},
		{"name": "CLEAN_TOOLS", "value": "false"},
		{"name": "BUILD_TYPE", "value": "N"},
		{"name": "SITE_PACK200", "value": "true"},
		{"name": "BUILD_TARGET", "value": "site.p2"},
		{"name": "JAVA_HOME", "value": "/shared/common/jdk-1.5.0-22.x86_64"},
		{"name": "SIGN_UPDATE_SITE", "value": "false"}
	], "": ""}'
	curl -X POST https://hudson.eclipse.org/hudson/job/papyrus-0.10-maintenance-extra-nightly/build -d token=token --data-urlencode json="$json" | grep --ignore-case error && exit -1
fi

########## maintenance 0.10 main nightly tests ##########
if [ $signalDate10MaintenanceNightlyTests -gt $lastPromoteDate10MaintenanceNightlyTests ]; then
	# mark the promote as done
	touch "$LAST_PROMOTE_FILE_0_10_MAINTENANCE_NIGHTLY_TESTS"

	waitUntilJobIsFinished "papyrus-0.10-maintenance-nightly-tests" "$JOB_FINISH_WAIT_TIMEOUT"

	dirBefore=$(pwd)
	echo "[$DATE] creating working dir"
	workingDir=$(mktemp -d)
	cd "$workingDir"

	# for the tests build, the build name and version are taken from the last main build since the artifacts 
	# must go to the same folder, and we want to be able to start several extra jobs after one single main job

	buildName=$(cat "$PROMOTE_SIGNAL_0_10_MAINTENANCE_NIGHTLY")
	version=$(cat "$PROMOTE_VERSION_0_10_MAINTENANCE_NIGHTLY")
	zipName="Papyrus-TestResults.zip"
	nfsURL="/shared/jobs/papyrus-0.10-maintenance-nightly-tests/lastSuccessful/archive/"
	hudsonURL="https://hudson.eclipse.org/hudson/job/papyrus-0.10-maintenance-nightly-tests/lastSuccessfulBuild/artifact/"

	cp "$nfsURL/${zipName}" . || wget --no-check-certificate "$hudsonURL/${zipName}"
	if [ ! -f "$zipName" ]; then echo "ERROR: $zipName (from Hudson) not found"; exit -2; fi
	echo "[$DATE] Testing zip integrity"
	unzip -t "$zipName"
	buildsDir="$DROPS_DIR/$version/$buildName"
	echo "[$DATE] publishing build (version='$version') to the builds directory '$buildsDir'..."
	unzip -o "$zipName" -d "$buildsDir"
	echo "[$DATE] setting access rights"
	setAccessRights "$buildsDir"

	echo "[$DATE] promote done"

	cd ${dirBefore}
	echo "[$DATE] deleting working dir"
	rm -rf "$workingDir"
	
	# TODO: re-enable when the job is implemented
	# echo "[$DATE] triggering Hudson tests build"
	# curl https://hudson.eclipse.org/hudson/job/papyrus-0.10-maintenance-extra-nightly-tests/buildWithParameters?token=token
fi

########## maintenance 0.10 extras nightly ##########
if [ $signalDate10MaintenanceExtraNightly -gt $lastPromoteDate10MaintenanceExtraNightly ]; then
	# mark the promote as done
	touch "$LAST_PROMOTE_FILE_0_10_MAINTENANCE_EXTRA_NIGHTLY"
	
	waitUntilJobIsFinished "papyrus-0.10-maintenance-extra-nightly" "$JOB_FINISH_WAIT_TIMEOUT"

	dirBefore=$(pwd)
	echo "[$DATE] creating working dir"
	workingDir=$(mktemp -d)
	cd "$workingDir"
	
	# for the extra build, the build name and version are taken from the last main build since the artifacts 
	# must go to the same folder, and we want to be able to start several extra jobs after one single main job
	
	buildName=$(cat "$PROMOTE_SIGNAL_0_10_MAINTENANCE_NIGHTLY")
	version=$(cat "$PROMOTE_VERSION_0_10_MAINTENANCE_NIGHTLY")
	zipName="Papyrus-Extra.zip"
	updateZipName="Papyrus-Extra-Update.zip"
	nfsURL="/shared/jobs/papyrus-0.10-maintenance-extra-nightly/lastSuccessful/archive/"
	hudsonURL="https://hudson.eclipse.org/hudson/job/papyrus-0.10-maintenance-extra-nightly/lastSuccessfulBuild/artifact/"
	
	# publish to existing drops folder
	cp "$nfsURL/${zipName}" . || wget --no-check-certificate "$hudsonURL/${zipName}"
	if [ ! -f "$zipName" ]; then echo "ERROR: $zipName (from Hudson) not found"; exit -2; fi
	echo "[$DATE] Testing zip integrity"
	unzip -t "$zipName"
	buildsDir="$DROPS_DIR/$version/$buildName"
	echo "[$DATE] publishing build (version='$version') to the builds directory '$buildsDir'..."
	unzip -o "$zipName" -d "$buildsDir"

	# publish to composite update site
	tmpDrop=$(mktemp -d)
	unzip "$zipName" -d "$tmpDrop"
	dirNameInZip=$(ls -1 "$tmpDrop")
	[ $(echo "$dirNameInZip" | wc -l) == 1 ] || { echo "one directory expected in zip"; exit 1; }
	rm -rf "$UPDATES_0_10_MAINTENANCE_EXTRA_NIGHTLY"
	unzip -o "$tmpDrop/$dirNameInZip/${updateZipName}" -d "$UPDATES_0_10_MAINTENANCE_EXTRA_NIGHTLY"
	
	echo "[$DATE] setting access rights"
	setAccessRights "$buildsDir"
	setAccessRights "$UPDATES_0_10_MAINTENANCE_EXTRA_NIGHTLY"
	
	echo "[$DATE] promote done"
	
	cd ${dirBefore}
	echo "[$DATE] deleting working dir"
	rm -rf "$workingDir"
	rm -rf "$tmpDrop"
	
	# trigger the extras tests build by using the Hudson Rest API
	# see http://wiki.hudson-ci.org/display/HUDSON/Remote+access+API
	
	echo "[$DATE] triggering Hudson extras tests build"
	json='{"parameter": [
		{"name": "BUCKMINSTER_LOGLEVEL", "value": "DEBUG"},
		{"name": "CLEAN_TP", "value": "true"},
		{"name": "CLEAN_WORKSPACE", "value": "true"},
		{"name": "CLEAN_OUTPUT", "value": "true"},
		{"name": "CLEAN_TOOLS", "value": "false"},
		{"name": "BUILD_TYPE", "value": "N"},
		{"name": "BUILD_TARGET", "value": "test"}
	], "": ""}'
	curl -X POST https://hudson.eclipse.org/hudson/job/papyrus-0.10-maintenance-extra-nightly-tests/build -d token=token --data-urlencode json="$json" | grep --ignore-case error && exit -1
fi

Back to the top