This repository has been archived by the owner on Nov 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
childlabel-build.xml
251 lines (173 loc) · 11.3 KB
/
childlabel-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
<?xml version="1.0" encoding="utf-8"?>
<project name="LTE" default="deploy-stage">
<!--
Build.xml file for CakePHP
Uses phing to create releases, and pear packages.
Based off of build.xml in doctrine.
Requires the d51PearPkg2 to be installed:
pear channel-discover pear.domain51.com
pear install domain51/Phing_d51PearPkg2Task
Use the `release` task to update VERSION.txt, and create a new tag.
Use the `build` task to create a pear package based on the current working copy.
Use the `clean` task to clean up packaging artifacts.
-->
<property name="package" value="${phing.project.name}" override="true" />
<property name="builddir" value="${project.basedir}/build" override="true" />
<property name="srcdir" value="${project.basedir}/src" override="true" />
<property name="testsdir" value="${project.basedir}/tests" override="true" />
<property name="appdirname" value="labelecommapp" override="true" />
<property name="appdir" value="${srcdir}/${appdirname}" override="true" />
<property name="tmpdir" value="${appdir}/tmp" override="true" />
<property name="logdir" value="${tmpdir}/logs" override="true" />
<property name="cake" value="${appdir}/Console/cake" override="true" />
<property name="runinapp" value="--app ${appdir}" override="true" />
<property name="domain" value="childlabel.oppoin.com" override="true" />
<property name="repository-uri" value="[email protected]:simkimsia/label-ecommerce.git" override="true" />
<property name="currentdir" value="current" override="true" />
<property name="server-configdir" value="config" override="true" />
<property name="configs" value="${appdirname}/Config/database.php,${appdirname}/Config/core.php,${appdirname}/Config/email.php" override="true" />
<property name="ugc.uploads" value="src/labelecommapp/webroot/files" override="true" />
<property name="removals" value="src/labelecommapp/webroot/files,src/labelecommapp/webroot/test.php" override="true" />
<property name="server-user" value="www-data" override="true" />
<property name="server-ip" value="166.78.124.182" override="true" />
<property name="host-used" value="${server-user}@${server-ip}" override="true" />
<property name="production.branch" value="master" override="true" />
<property name="production.sitedir" value="/var/virtual/${domain}/" override="true" />
<property name="stage.branch" value="develop" override="true" />
<property name="stage.sitedir" value="/var/virtual/stage.${domain}/" override="true" />
<property name="runincurrentapp" value="${runinapp}" override="true" />
<property name="runinworkspaceapp" value="${runinapp}" override="true" />
<property name="production.sitedir.current" value="${production.sitedir}current" override="true" />
<property name="stage.sitedir.current" value="${stage.sitedir}current/" override="true" />
<property name="production.sitedir.current.app" value="${production.sitedir.current}${appdirname}" override="true" />
<property name="stage.sitedir.current.app" value="${stage.sitedir.current}${appdirname}" override="true" />
<tstamp>
<format property="build.time" pattern="%Y_%m_%d_%H_%M_%S" />
</tstamp>
<!-- ============================================ -->
<!-- Target: predeploy -->
<!-- ============================================ -->
<target name="predeploy-stage" >
<echo msg="Preparing deploy on rackspace server for stage environment" />
<property name="environment" value="stage" override="true"/>
<property name="environment.branch" value="${stage.branch}" override="true"/>
<property name="environment.sitedir" value="${stage.sitedir}" override="true"/>
<property name="runincurrentapp" value="--app ${environment.sitedir}${appdirname}" override="true" />
<property name="runinworkspaceapp" value="${runinapp}" override="true" />
<echo msg="Deploying on rackspace server for stage environment ... " />
</target>
<target name="setup-environments" description="define some commonly used properties">
<property name="environment.sitedir.current" value="${environment.sitedir}current/" override="true"/>
<property name="environment.sitedir.current.src" value="${environment.sitedir.current}src/" override="true"/>
<property name="environment.sitedir.current.src.app" value="${environment.sitedir.current.src}${appdirname}/" override="true"/>
<property name="cd.current" value="cd ${environment.sitedir.current}" override="true"/>
<property name="cd.current.src" value="cd ${environment.sitedir.current.src}" override="true"/>
<property name="cd.current.src.app" value="cd ${environment.sitedir.current.src.app}" override="true"/>
</target>
<target name="deploy-stage" depends="predeploy-stage,setup-environments,gitclone,update-symlink-current,symlink-server-configs,removefiles-from-cloned,symlink-ugc,reboot-services,chmod-tmp,gitsubmodule-plugins,run-composer,remove-buildtime-folders,run-migrations,run-assetcompress,run-clearcache,run-acosync">
<echo msg="Finished deploying on rackspace server for stage environment!" />
</target>
<target name="gitclone">
<echo msg="gitclone ${environment.branch} branch code to ${environment} environment" />
<exec command="ssh -A ${host-used} 'git clone -b ${environment.branch} ${repository-uri} ${environment.sitedir}${build.time}'"
outputProperty="result" escape="false"/>
<echo msg="${result}" />
</target>
<target name="gitsubmodule-plugins">
<echo msg="Git submodule plugins in ${appdirname}" />
<exec command="ssh -A ${host-used} '${cd.current} && git submodule update --init --recursive'"
outputProperty="result" escape="false"/>
<echo msg="${result}" />
</target>
<!-- ============================================ -->
<!-- Target: removefiles-from-cloned -->
<!-- ============================================ -->
<target name="removefiles-from-cloned">
<echo msg="remove files incompatible with ${environment} deployment" />
<foreach list="${removals}" param="dir" target="remove-dir-recursively" />
</target>
<target name="remove-dir-recursively">
<echo msg="removing ${dir} inside ${environment.sitedir}${build.time} recursively" />
<exec command="ssh -A ${host-used} 'rm -rf ${environment.sitedir}${build.time}/${dir}'" outputProperty="result" />
<echo msg="${result}" />
</target>
<target name="symlink-server-configs">
<echo msg="symlink config files into ${environment} deployment" />
<foreach list="${configs}" param="dir" target="symlink-file" />
</target>
<target name="symlink-file">
<echo msg="symlink ${dir} inside ${environment.sitedir}${build.time} recursively" />
<exec command="ssh -A ${host-used} 'ln -s ${environment.sitedir}config/${dir} ${environment.sitedir}${build.time}/src/${dir}'" outputProperty="result" />
<echo msg="${result}" />
</target>
<!-- ============================================ -->
<!-- Target: symlink-ugc -->
<!-- ============================================ -->
<target name="symlink-ugc">
<echo msg="symlink user generated files into ${environment} deployment" />
<exec command="ssh -A ${host-used} 'ln -s ${environment.sitedir}uploads ${environment.sitedir}${build.time}/${ugc.uploads}'" outputProperty="result" />
<echo msg="${result}" />
</target>
<target name="reboot-services">
<echo msg="Clearing APC cache" />
<!-- clear the APC cache if it is already there -->
<exec command="ssh -A ${host-used} 'cd ${environment.sitedir}${build.time} && ./RunApcClearCache.sh'" outputProperty="result" escape="false">
</exec>
<echo msg="${result}" />
<exec command="sudo service php5-fpm restart" outputProperty="result" />
<echo msg="${result}" />
</target>
<!-- ============================================ -->
<!-- Target: chmod tmp folder -->
<!-- ============================================ -->
<target name="chmod-tmp">
<echo msg="opening 777 access to tmp folders" />
<!-- remove the symlink if it is already there -->
<exec command="ssh -A ${host-used} 'chmod 777 ${environment.sitedir}${build.time}/${appdirname}/tmp -R'" outputProperty="result" />
<exec command="ssh -A ${host-used} 'chmod 777 ${environment.sitedir}${build.time}/src/lib/ -R'" outputProperty="result" />
<echo msg="${result}" />
</target>
<target name="update-symlink-current">
<echo msg="Updating symlink at current to latest cloned files for ${environment} deployment" />
<!-- remove the symlink if it is already there -->
<exec command="ssh -A ${host-used} 'rm ${environment.sitedir}current'" outputProperty="result" />
<!-- <delete dir="${environment.sitedir}current" quiet='true' /> -->
<exec command="ssh -A ${host-used} 'ln -s ${environment.sitedir}${build.time} ${environment.sitedir}current'" outputProperty="result" />
<echo msg="${result}" />
</target>
<target name="run-composer">
<echo msg="Running Composer in ${appdirname}" />
<exec command="ssh -A ${host-used} '${cd.current.src.app} && php composer.phar update'" outputProperty="result" escape="false" />
<echo msg="${result}" />
</target>
<target name="run-assetcompress">
<echo msg="Running AssetCompress in ${appdirname}" />
<exec command="ssh -A ${host-used} '${cd.current.src.app} && Console/cake AssetCompress.AssetCompress build_ini'" outputProperty="result" escape="false" />
<echo msg="${result}" />
</target>
<target name="run-migrations">
<echo msg="Running Migrations in ${appdirname}" />
<exec command="ssh -A ${host-used} '${cd.current.src.app} && Console/cake Migrations.migration run all'" outputProperty="result" escape="false" />
<echo msg="${result}" />
</target>
<target name="run-clearcache">
<echo msg="Running ClearCache in ${appdirname}" />
<exec command="ssh -A ${host-used} '${cd.current.src.app} && Console/cake ClearCache.clear_cache'" outputProperty="result" escape="false" />
<echo msg="${result}" />
</target>
<target name="run-acosync">
<echo msg="Running AclExtras.AclExtras aco_sync in ${appdirname}" />
<exec command="ssh -A ${host-used} '${cd.current.src.app} && Console/cake AclExtras.AclExtras aco_sync'" outputProperty="result" escape="false" />
<echo msg="${result}" />
</target>
<target name="remove-buildtime-folders">
<echo msg="Removing any extra build time folders in ${appdirname}" />
<exec command="ssh -A ${host-used} '${cd.current} && ./RemoveBuildTimeFolders.sh'" outputProperty="result" escape="false" />
<echo msg="${result}" />
</target>
<target name="run-tests">
<echo msg="Running tests in ${appdirname}" />
<exec command="ssh -A ${host-used} '${cd.current.src.app} && Console/cake run the test commands'" outputProperty="result" escape="false" />
<echo msg="${result}" />
</target>
</project>