forked from liferay/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build-test-staging.xml
137 lines (104 loc) · 4.65 KB
/
build-test-staging.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
<?xml version="1.0"?>
<project basedir="." default="test" name="portal-test-staging-mysql" xmlns:antelope="antlib:ise.antelope.tasks">
<import file="build-test.xml" />
<propertycopy from="custom.database.zip.url[${env.CI_TEST_SUITE}]" name="custom.database.zip.url" silent="true" />
<propertycopy from="custom.database.name[${env.CI_TEST_SUITE}]" name="custom.database.name" silent="true" />
<target name="rebuild-staging-database">
<mirrors-get
dest="${liferay.home}"
src="${custom.database.zip.url}"
/>
<unzip
dest="${liferay.home}"
src="${liferay.home}/${custom.database.name}.zip"
/>
<get-database-property property.name="database.docker.image" />
<if>
<isset property="database.docker.image" />
<then>
<get-database-property property.name="database.host" />
<get-database-property property.name="database.password" />
<get-database-property property.name="database.schema" />
<get-database-property property.name="database.username" />
<get-database-property property.name="database.version" />
<property location="import-database.sh" name="import.database.sh.file.path" />
<echo>Database Type is: ${database.type}</echo>
<if>
<equals arg1="${database.type}" arg2="mysql" />
<then>
<antcall target="rebuild-database">
<param name="database.type" value="${database.type}" />
<param name="sql.dir" value="sql/create-bare/" />
<param name="sql.file" value="create-bare-mysql.sql" />
</antcall>
<echo file="${import.database.sh.file.path}">
<![CDATA[
#!/bin/bash
mysql --database=${database.schema} --password=${database.password} --user=${database.username} < /tmp/${database.type}.sql
]]>
</echo>
<property name="docker.database.dest.path" value="/tmp/${database.type}.sql" />
<property name="import.database.src.path" value="${liferay.home}/${database.type}.sql" />
</then>
<elseif>
<equals arg1="${database.type}" arg2="oracle" />
<then>
<property location="${project.dir}/import-database.sql" name="oracle.setup.file.path" />
<echo file="${oracle.setup.file.path}">
<![CDATA[
drop user liferay cascade;
drop user liferay_cms cascade;
drop tablespace liferay including contents and datafiles;
drop tablespace liferay_cms including contents and datafiles;
create user liferay identified by "123456";
create user liferay_cms identified by "123456";
create or replace directory DATA_PUMP_DIR as '/tmp/data_pump_dir';
select directory_name, directory_path from dba_directories where directory_name='DATA_PUMP_DIR';
create tablespace liferay datafile 'liferay.dbf' size 2g autoextend on;
create tablespace liferay_cms datafile 'liferay_cms.dbf' size 2g autoextend on;
alter user liferay default tablespace liferay;
alter user liferay_cms default tablespace liferay_cms;
grant unlimited tablespace to liferay;
grant unlimited tablespace to liferay_cms;
grant create session,create table to liferay;
grant create session,create table to liferay_cms;
grant connect,resource to liferay;
grant connect,resource to liferay_cms;
grant read, write on directory DATA_PUMP_DIR to liferay;
grant read, write on directory DATA_PUMP_DIR to liferay_cms;
grant exp_full_database,imp_full_database to liferay;
grant exp_full_database,imp_full_database to liferay_cms;
quit;
]]>
</echo>
<echo file="${import.database.sh.file.path}">
<![CDATA[
#!/bin/bash
impdp ${oracle.admin.user}/${oracle.admin.password} DIRECTORY=DATA_PUMP_DIR dumpfile=${custom.database.name}.dmp table_exists_action=replace full=y
]]>
</echo>
<execute>
<![CDATA[
docker exec ${database.host} mkdir -p /tmp/data_pump_dir
docker exec ${database.host} chown -R oracle:oracle /tmp/data_pump_dir
docker cp ${oracle.setup.file.path} ${database.host}:/tmp/import-database.sql
docker exec ${database.host} sqlplus ${oracle.admin.user}/${oracle.admin.password} @/tmp/import-database.sql
]]>
</execute>
<property name="docker.database.dest.path" value="/tmp/data_pump_dir/${custom.database.name}.dmp" />
<property name="import.database.src.path" value="${liferay.home}/${custom.database.name}.dmp" />
</then>
</elseif>
</if>
<execute>
<![CDATA[
docker cp ${import.database.sh.file.path} ${database.host}:/tmp/import-database.sh
docker cp ${import.database.src.path} ${database.host}:${docker.database.dest.path}
docker exec ${database.host} /bin/bash /tmp/import-database.sh
]]>
</execute>
<echo>Import process is finished</echo>
</then>
</if>
</target>
</project>