Fork me on GitHub
Fork me on GitHub

Jenkins+Ant自动化

最近需要帮部门一个ant项目做持续集成和发布,该项目有9个svn地址,还有比较多的依赖,踩了不少坑,搞完记录下。

安装JDK 8

# mkdir /usr/java
# tar zxf /usr/local/jdk-8u73-linux-x64.gz -C /usr/java/
# vim /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_73
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
# source /etc/profile

安装Ant

[root@res local]# wget http://mirror.bit.edu.cn/apache//ant/binaries/apache-ant-1.10.5-bin.zip
[root@res local]# unzip -oq apache-ant-1.10.5-bin.zip 
[root@res local]# ln -sv apache-ant-1.10.5 ant

Jenkins配置SVN地址

1.配置svn账号密码
输入Jenkins访问地址,在首页左侧菜单有个“Credentials”,点击进去。在点击左侧菜单“Credentials”下的“System”,再点击右侧正文的“Global credentials (unrestricted)”。

点击左侧菜单的“Add Credentials”,输入svn的账号密码,顺便添加一些描述信息。

2.配置svn地址
找到对应的项目,点击“配置”,点击“源码管理”,选择“Subversion”。输入9个项目的svn地址。

需要注意的时,每个项目需要给它指定一个目录。否则最后一个项目拉下来的代码会把之前的代码全部覆盖掉。

外部依赖

由于需要很多外部jar包和其它的一些应用,所以必须在Jenkins服务器上创建并放好这些依赖。

另外还需要创建ant编译时用到一些目录

[root@res opt]# mkdir -p /opt/emap_build_workspace/out

编写build.xml文件

build.xml文件内容如下:

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
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="publish_jar">
<property environment="env" />
<property name="debuglevel" value="source,lines,vars" />
<property name="encoding" value="UTF-8" />
<property name="out" value="/opt/emap_build_workspace/out/out" />
<property name="out_tmp" value="/opt/emap_build_workspace/out/out_tmp" />
<property name="out_pub_classes" value="/opt/emap_build_workspace/out/out_tmp_pub" />
<property name="work_home" value="/root/.jenkins/workspace/gemini"/>
<property name="pedestal_home" value="/opt/emap"/>
<property name="base_home" value="/opt/wiseduAppGroups" />
<property name="tomcat_home_lib" value="/opt/emap" />
<property name="emapAuth_classes" value="/opt/wiseduAppGroups/emapAuth/pub_classes" />
<property name="emapcomponent_classes" value="/opt/wiseduAppGroups/emapcomponent/pub_classes"/>
<property name="zipOut" value="/opt/emap_build_workspace/out/out.zip" />
<path id="emap_prj_lib">
<fileset dir="${base_home}/$BASE/lib/">
<include name="*.jar" />
</fileset>
<fileset dir="${base_home}/$BASE/ext">
<include name="**/*.jar" />
</fileset>
<fileset dir="${tomcat_home_lib}">
<include name="jsp-api.jar" />
<include name="servlet-api.jar" />
</fileset>
<fileset dir="${pedestal_home}/WEB-INF/lib/">
<include name="*.jar" />
</fileset>
</path>
<path id="current_lib">
<fileset dir="${out_tmp}/lib/">
<include name="*.jar" />
</fileset>
</path>
<path id="pub_class_lib">
<pathelement location="${out_pub_classes}"/>
</path>
<path id="emapAuth_lib">
<pathelement location="${emapAuth_classes}"/>
</path>
<path id="emapcomponent_lib">
<pathelement location="${emapcomponent_classes}"/>
</path>
<path id="emapsender_lib">
<pathelement location="${out}/emapsender/pub_classes"/>
</path>
<path id="emapfunauth_lib">
<pathelement location="${out}/emapfunauth/pub_classes"/>
</path>
<path id="emapflow_lib">
<pathelement location="${out}/emapflow/pub_classes"/>
</path>
<path id="flowstatistics_lib">
<pathelement location="${out}/flowstatistics/pub_classes"/>
</path>
<path id="eetablecore_lib">
<pathelement location="${out}/eetablecore/pub_classes"/>
</path>
<path id="emapturing_lib">
<pathelement location="${out}/emapturing/pub_classes"/>
</path>
<target name="cleanall">
</target>
<target name="build.1.5">
<delete dir="${out}"/>
<mkdir dir="${out}"/>
<mkdir dir="${out_classes}"/>
<mkdir dir="${out_pub_classes}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out_pub_classes}"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<src path="${out_tmp}/pub_src" />
<classpath refid="emap_prj_lib" />
</javac>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out_classes}"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<src path="${out_tmp}/src" />
<classpath refid="emap_prj_lib" />
<classpath refid="pub_class_lib" />
</javac>
<copy includeemptydirs="false" todir="${out}">
<fileset dir="${out_tmp}">
<include name="app_info.xml"/>
<include name="EMAP_APP"/>
</fileset>
</copy>
<delete dir="${out_tmp}"/>
</target>
<target name="init.project">
<delete dir="${out_tmp}" />
<mkdir dir="${out_tmp}" />
<copy includeemptydirs="false" todir="${out_tmp}">
<fileset dir="${jdkv1.5}">
<exclude name=".*"/>
<exclude name="classes"/>
<exclude name="pub_classes"/>
<exclude name="build.xml"/>
</fileset>
</copy>
</target>
<target name="init">
<delete dir="${out}"/>
<mkdir dir="${out}"/>
<delete dir="${out_tmp}"/>
<mkdir dir="${out_tmp}"/>
<delete dir="${out_pub_classes}"/>
<mkdir dir="${out_pub_classes}"/>
</target>
<target name="build_emapsender">
<copy includeemptydirs="false" todir="${out_tmp}">
<fileset dir="${work_home}/emapsender">
<exclude name=".*"/>
<exclude name=".settings/**"/>
<exclude name="classes/**"/>
<exclude name="pub_classes/**"/>
<exclude name="build.xml"/>
</fileset>
</copy>
<mkdir dir="${out}/emapsender/pub_classes"/>
<mkdir dir="${out}/emapsender/classes"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out_pub_classes}"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<src path="${out_tmp}/pub_src" />
<classpath refid="emap_prj_lib" />
</javac>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out}/emapsender/classes"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<src path="${out_tmp}/src" />
<classpath refid="emap_prj_lib" />
<classpath refid="pub_class_lib" />
</javac>
<copy includeemptydirs="false" todir="${out}/emapsender/pub_classes">
<fileset dir="${out_pub_classes}">
<include name="**/*.class"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="${out}/emapsender">
<fileset dir="${out_tmp}">
<include name="app_info.xml"/>
<include name="EMAP_APP"/>
</fileset>
</copy>
</target>
<target name="build_emaptaskcenter">
<delete dir="${out_tmp}"/>
<mkdir dir="${out_tmp}"/>
<copy includeemptydirs="false" todir="${out_tmp}">
<fileset dir="${work_home}/emaptaskcenter">
<exclude name=".*"/>
<exclude name=".settings/**"/>
<exclude name="classes/**"/>
<exclude name="pub_classes/**"/>
<exclude name="build.xml"/>
</fileset>
</copy>
<mkdir dir="${out}/emaptaskcenter/classes"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out}/emaptaskcenter/classes"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<src path="${out_tmp}/src" />
<classpath refid="emap_prj_lib" />
</javac>
<copy includeemptydirs="false" todir="${out}/emaptaskcenter">
<fileset dir="${out_tmp}">
<include name="app_info.xml"/>
<include name="EMAP_APP"/>
<include name="web"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="${out}/emaptaskcenter/classes">
<fileset dir="${out_tmp}/src">
<exclude name="**/*.class"/>
<exclude name="**/*.java"/>
<exclude name="*.java"/>
<exclude name="*.class"/>
</fileset>
</copy>
</target>
<target name="build_emapflow">
<delete dir="${out_tmp}"/>
<mkdir dir="${out_tmp}"/>
<delete dir="${out_pub_classes}"/>
<mkdir dir="${out_pub_classes}"/>
<copy includeemptydirs="false" todir="${out_tmp}">
<fileset dir="${work_home}/emapflow">
<exclude name=".*"/>
<exclude name=".settings/**"/>
<exclude name="classes/**"/>
<exclude name="pub_classes/**"/>
<exclude name="build.xml"/>
</fileset>
</copy>
<mkdir dir="${out}/emapflow/classes"/>
<mkdir dir="${out}/emapflow/pub_classes"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out_pub_classes}"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint:-options"/>
<src path="${out_tmp}/pub_src" />
<classpath refid="emap_prj_lib" />
<classpath refid="current_lib" />
<classpath refid="emapAuth_lib" />
</javac>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out}/emapflow/classes"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint:-options"/>
<src path="${out_tmp}/src" />
<classpath refid="emap_prj_lib" />
<classpath refid="current_lib" />
<classpath refid="emapAuth_lib" />
<classpath refid="pub_class_lib" />
</javac>
<copy includeemptydirs="false" todir="${out}/emapflow">
<fileset dir="${out_tmp}">
<exclude name="src/**"/>
<exclude name="pub_src/**"/>
<exclude name="config/propertiesPanel.json"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="${out}/emapflow/pub_classes">
<fileset dir="${out_pub_classes}">
<include name="**/*.class"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="${out}/emapflow/classes">
<fileset dir="${out_tmp}/src">
<exclude name="**/*.class"/>
<exclude name="**/*.java"/>
<exclude name="*.java"/>
<exclude name="*.class"/>
</fileset>
</copy>
</target>
<target name="build_flowstatistics">
<delete dir="${out_tmp}"/>
<mkdir dir="${out_tmp}"/>
<delete dir="${out_pub_classes}"/>
<mkdir dir="${out_pub_classes}"/>
<copy includeemptydirs="false" todir="${out_tmp}">
<fileset dir="${work_home}/flowstatistics">
<exclude name=".*"/>
<exclude name=".settings/**"/>
<exclude name="classes/**"/>
<exclude name="pub_classes/**"/>
<exclude name="build.xml"/>
</fileset>
</copy>
<mkdir dir="${out}/flowstatistics/pub_classes"/>
<mkdir dir="${out}/flowstatistics/classes"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out_pub_classes}"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<src path="${out_tmp}/pub_src" />
<classpath refid="emap_prj_lib" />
</javac>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out}/flowstatistics/classes"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<src path="${out_tmp}/src" />
<classpath refid="emap_prj_lib" />
<classpath refid="pub_class_lib" />
</javac>
<copy includeemptydirs="false" todir="${out}/flowstatistics/pub_classes">
<fileset dir="${out_pub_classes}">
<include name="**/*.class"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="${out}/flowstatistics">
<fileset dir="${out_tmp}">
<exclude name="src/**"/>
<exclude name="pub_src/**"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="${out}/flowstatistics/classes">
<fileset dir="${out_tmp}/src">
<exclude name="**/*.class"/>
<exclude name="**/*.java"/>
<exclude name="*.java"/>
<exclude name="*.class"/>
</fileset>
</copy>
</target>
<target name="build_emapturing">
<delete dir="${out_tmp}"/>
<mkdir dir="${out_tmp}"/>
<delete dir="${out_pub_classes}"/>
<mkdir dir="${out_pub_classes}"/>
<copy includeemptydirs="false" todir="${out_tmp}">
<fileset dir="${work_home}/emapturing">
<exclude name=".*"/>
<exclude name=".settings/**"/>
<exclude name="classes/**"/>
<exclude name="pub_classes/**"/>
<exclude name="build.xml"/>
</fileset>
</copy>
<mkdir dir="${out}/emapturing/classes"/>
<mkdir dir="${out}/emapturing/pub_classes"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out_pub_classes}"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint:-options"/>
<src path="${out_tmp}/pub_src" />
<classpath refid="emap_prj_lib" />
<classpath refid="emapcomponent_lib" />
</javac>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out}/emapturing/classes"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint:-options"/>
<src path="${out_tmp}/src" />
<classpath refid="emap_prj_lib" />
<classpath refid="emapcomponent_lib" />
<classpath refid="pub_class_lib" />
</javac>
<copy includeemptydirs="false" todir="${out}/emapturing">
<fileset dir="${out_tmp}">
<exclude name="src/**"/>
<exclude name="pub_src/**"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="${out}/emapturing/pub_classes">
<fileset dir="${out_pub_classes}">
<include name="**/*.class"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="${out}/emapturing/classes">
<fileset dir="${out_tmp}/src">
<exclude name="**/*.class"/>
<exclude name="**/*.java"/>
<exclude name="*.java"/>
<exclude name="*.class"/>
</fileset>
</copy>
</target>
<target name="build_emapfunauth">
<delete dir="${out_tmp}"/>
<mkdir dir="${out_tmp}"/>
<delete dir="${out_pub_classes}"/>
<mkdir dir="${out_pub_classes}"/>
<copy includeemptydirs="false" todir="${out_tmp}">
<fileset dir="${work_home}/emapfunauth">
<exclude name=".*"/>
<exclude name=".settings/**"/>
<exclude name="classes/**"/>
<exclude name="pub_classes/**"/>
<exclude name="build.xml"/>
</fileset>
</copy>
<mkdir dir="${out}/emapfunauth/classes"/>
<mkdir dir="${out}/emapfunauth/pub_classes"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out_pub_classes}"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint:-options"/>
<src path="${out_tmp}/pub_src" />
<classpath refid="emap_prj_lib" />
<classpath refid="emapAuth_lib" />
<classpath refid="emapcomponent_lib" />
</javac>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out}/emapfunauth/classes"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint:-options"/>
<src path="${out_tmp}/src" />
<classpath refid="emap_prj_lib" />
<classpath refid="emapAuth_lib" />
<classpath refid="emapcomponent_lib" />
<classpath refid="pub_class_lib" />
<classpath refid="emapsender_lib" />
</javac>
<copy includeemptydirs="false" todir="${out}/emapfunauth">
<fileset dir="${out_tmp}">
<exclude name="src/**"/>
<exclude name="pub_src/**"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="${out}/emapfunauth/pub_classes">
<fileset dir="${out_pub_classes}">
<include name="**/*.class"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="${out}/emapfunauth/classes">
<fileset dir="${out_tmp}/src">
<exclude name="**/*.class"/>
<exclude name="**/*.java"/>
<exclude name="*.java"/>
<exclude name="*.class"/>
</fileset>
</copy>
</target>
<target name="build_eetablecore">
<delete dir="${out_tmp}"/>
<mkdir dir="${out_tmp}"/>
<delete dir="${out_pub_classes}"/>
<mkdir dir="${out_pub_classes}"/>
<copy includeemptydirs="false" todir="${out_tmp}">
<fileset dir="${work_home}/eetablecore">
<exclude name=".*"/>
<exclude name=".settings/**"/>
<exclude name="classes/**"/>
<exclude name="pub_classes/**"/>
<exclude name="build.xml"/>
</fileset>
</copy>
<mkdir dir="${out}/eetablecore/classes"/>
<mkdir dir="${out}/eetablecore/pub_classes"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out_pub_classes}"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint:-options"/>
<src path="${out_tmp}/pub_src" />
<classpath refid="emap_prj_lib" />
<classpath refid="emapflow_lib" />
</javac>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out}/eetablecore/classes"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint:-options"/>
<src path="${out_tmp}/src" />
<classpath refid="emap_prj_lib" />
<classpath refid="pub_class_lib" />
<classpath refid="emapflow_lib" />
</javac>
<copy includeemptydirs="false" todir="${out}/eetablecore">
<fileset dir="${out_tmp}">
<exclude name="src/**"/>
<exclude name="pub_src/**"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="${out}/eetablecore/pub_classes">
<fileset dir="${out_pub_classes}">
<include name="**/*.class"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="${out}/eetablecore/classes">
<fileset dir="${out_tmp}/src">
<exclude name="**/*.class"/>
<exclude name="**/*.java"/>
<exclude name="*.java"/>
<exclude name="*.class"/>
</fileset>
</copy>
</target>
<target name="build_eetablemanage">
<delete dir="${out_tmp}"/>
<mkdir dir="${out_tmp}"/>
<delete dir="${out_pub_classes}"/>
<mkdir dir="${out_pub_classes}"/>
<copy includeemptydirs="false" todir="${out_tmp}">
<fileset dir="${work_home}/eetablemanage">
<exclude name=".*"/>
<exclude name=".settings/**"/>
<exclude name="classes/**"/>
<exclude name="pub_classes/**"/>
<exclude name="build.xml"/>
</fileset>
</copy>
<!--前端编译打包-->
<exec executable="/bin/sh" failonerror="true">
<arg value="-c" />
<arg value="/root/.jenkins/workspace/tgbuilder release ${out_tmp}/web/" />
</exec>
<mkdir dir="${out}/eetablemanage/classes"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out}/eetablemanage/classes"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint:-options"/>
<src path="${out_tmp}/src" />
<classpath refid="emap_prj_lib" />
<classpath refid="current_lib" />
<classpath refid="emapAuth_lib" />
<classpath refid="emapflow_lib" />
<classpath refid="eetablecore_lib" />
<classpath refid="emapfunauth_lib" />
<classpath refid="emapturing_lib" />
<classpath refid="flowstatistics_lib" />
</javac>
<copy includeemptydirs="false" todir="${out}/eetablemanage">
<fileset dir="${out_tmp}">
<exclude name="src/**"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="${out}/eetablemanage/classes">
<fileset dir="${out_tmp}/src">
<exclude name="**/*.class"/>
<exclude name="**/*.java"/>
<exclude name="*.java"/>
<exclude name="*.class"/>
</fileset>
</copy>
</target>
<target name="build_skylobby">
<delete dir="${out_tmp}"/>
<mkdir dir="${out_tmp}"/>
<delete dir="${out_pub_classes}"/>
<mkdir dir="${out_pub_classes}"/>
<copy includeemptydirs="false" todir="${out_tmp}">
<fileset dir="${work_home}/skylobby">
<exclude name=".*"/>
<exclude name=".settings/**"/>
<exclude name="classes/**"/>
<exclude name="pub_classes/**"/>
<exclude name="build.xml"/>
</fileset>
</copy>
<mkdir dir="${out}/skylobby/classes"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="${out}/skylobby/classes"
encoding="${encoding}" source="1.5" target="1.5" includeantruntime="on">
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint:-options"/>
<src path="${out_tmp}/src" />
<classpath refid="emap_prj_lib" />
<classpath refid="eetablecore_lib" />
</javac>
<copy includeemptydirs="false" todir="${out}/skylobby">
<fileset dir="${out_tmp}">
<exclude name="src/**"/>
</fileset>
</copy>
<copy includeemptydirs="false" todir="${out}/skylobby/classes">
<fileset dir="${out_tmp}/src">
<exclude name="**/*.class"/>
<exclude name="**/*.java"/>
<exclude name="*.java"/>
<exclude name="*.class"/>
</fileset>
</copy>
</target>
<target name="end">
<delete dir="${out_tmp}"/>
<delete dir="${out_pub_classes}"/>
<zip destfile="${zipOut}/" basedir="${out}" />
<delete dir="${out}"/>
</target>
<!--
<target depends="init.project,build.1.5" name="build"></target>
<target depends="init,build_emapsender,build_emapfunauth" name="build"></target>
-->
<target depends="init,build_emapsender,build_emaptaskcenter,build_emapflow,build_flowstatistics,build_emapturing,build_emapfunauth,build_eetablecore,build_skylobby,build_eetablemanage,end" name="build"></target>
</project>

发布脚本

需要配置Jenkins服务器上运行jenkins服务的用户登录目标机器不需要输入用户名和密码。

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
# Define constant
GEMINI_IP=172.16.206.32
TOMCAT_HOME=/opt/tomcat-gemini-dev
GEMINI_HOME=/opt/wiseduAppGroups/gemini_dev
BACKUPS_HOME=/opt/gemini_backups
# Stop tomcat.
ssh root@${GEMINI_IP} "${TOMCAT_HOME}/bin/shutdown.sh" &>/dev/null
sleep 15
# Check the stop is successful or not. If until not, kill the tomcat process.
if ssh root@${GEMINI_IP} 'ps -ef|grep "tomcat-gemini-dev" |grep -v "grep"' &>/dev/null; then
tomcat_pid=`ssh root@${GEMINI_IP} "ps -ef | grep tomcat-gemini-dev | grep -v "grep" | awk '{print $2}'"`
ssh root@${GEMINI_IP} "kill -9 ${tomcat_pid}"
fi
# Check the stop is successful or not.
if ssh root@${GEMINI_IP} 'ps -ef|grep "tomcat-gemini-dev" |grep -v "grep"' &>/dev/null; then
echo "Tomcat stop failed.Please check the problem."
exit 5
fi
# Backup previous version.
ssh root@${GEMINI_IP} "cd ${GEMINI_HOME}; tar zcf gemini$(date +%Y%m%d).tar.gz eetablecore eetablemanage emapflow emapfunauth emapsender emaptaskcenter emapturing flowstatistics skylobby"
ssh root@${GEMINI_IP} "mv -f ${GEMINI_HOME}/gemini$(date +%Y%m%d).tar.gz ${BACKUPS_HOME}/"
ssh root@${GEMINI_IP} "cd ${GEMINI_HOME}; rm -rf eetablecore eetablemanage emapflow emapfunauth emapsender emaptaskcenter emapturing flowstatistics skylobby"
# Copy the newest zip to host.
scp /opt/emap_build_workspace/out/out.zip root@${GEMINI_IP}:${GEMINI_HOME}/ &>/dev/null
ssh root@${GEMINI_IP} "cd ${GEMINI_HOME}; unzip -oq ${GEMINI_HOME}/out.zip" #不进入目录解压不了
ssh root@${GEMINI_IP} "rm -f ${GEMINI_HOME}/out.zip"
# Start the tomcat.
ssh root@${GEMINI_IP} "${TOMCAT_HOME}/bin/startup.sh" &>/dev/null

邮件配置

我使用的是 Extended Email Publisher这个插件。在配置构建完发送邮件,遇到一个问题:
测试邮件能发出去,但是构建完收不到邮件。构建日志显示邮件触发器已经触发了。
解决:点开高级设置,


修改为:

但是发现还是收不到邮件。

网上找到了答案,需要在Jenkins系统设置里配置 Extended E-mail Notification,如下:

Jenkins本身也有发邮件的配置,当你使用了其他发邮件的插件时,需要配置这些插件的发件人账号密码等。