-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfabfile.py
121 lines (99 loc) · 3.4 KB
/
fabfile.py
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
import os
from fabric.api import local, run, cd, env, lcd, task
from fabric.operations import put
from fabric.colors import green, red
from cwsfabric import config, to, portal
# Removes cached class files & runs ant to compile war
@task
def compile():
local("rm -rf docroot/WEB-INF/classes && ant && date")
# Compiles and deploys war file to node
@task
def deploy():
to.abort_if_no_environment()
compile()
portal.deploy_war(env.war_file, env.webapp_dir)
# Deploys the latest generated war file for ecs and deploys it to node
@task
def deploy_ecs():
filename = get_latest_ecs_war()
portal.deploy_war(filename, env.webapp_dir)
print(green("Deployed " + filename))
# Removes unit test code, compiles/generate war file
@task
def build_ecs_war():
remove_tests()
print(green("Removed tests code from war"))
compile()
print(green("Generated war file"))
restore_tests()
print(green("Restored tests into code"))
ecs_filename = get_file_name()
with lcd(env.liferay_dist_dir):
local("cp " + env.war_file + " " + ecs_filename)
print(green("ECS File: " + env.liferay_dist_dir + ecs_filename))
def remove_tests():
local("mv docroot/WEB-INF/src/edu/osu/cws/evals/tests/ /tmp/")
def restore_tests():
local("mv /tmp/tests/ docroot/WEB-INF/src/edu/osu/cws/evals/tests/")
# Gets the current version of the app by reading version.txt
def get_version():
version_file = file("VERSION.txt")
version = version_file.read()
version_file.close()
version = version.strip()
return version
# Generates the filename for ecs builds. It uses the rc or release suffix and the
# prod_prefix. It uses a counter for the suffix, if we've already generated the war
# for ecs for this version before.
def get_file_name():
name_to_check = env.prod_prefix + get_version()
if env.is_rc == True:
name_to_check += "-rc" + get_rc_number(name_to_check)
else:
name_to_check += "-release" + get_release_number(name_to_check)
name_to_check += ".war"
return name_to_check
def get_rc_number(filename, increment=True):
i = 1
found_rc_number = False
while found_rc_number == False:
name_to_check = filename + "-rc" + str(i) + ".war"
if os.path.isfile(env.liferay_dist_dir + name_to_check):
i = i+1
else:
found_rc_number = True
if increment == False and i > 1:
i = i-1
return str(i)
def get_release_number(filename, increment=True):
i = 1
found_rc_number = False
while found_rc_number == False:
name_to_check = filename + "-release" + str(i) + ".war"
if os.path.isfile(env.liferay_dist_dir + name_to_check):
i = i+1
else:
found_rc_number = True
if increment == False and i > 1:
i = i-1
return str(i)
def get_latest_ecs_war():
filename = env.prod_prefix + get_version()
if env.is_rc == True:
filename += "-rc" + get_rc_number(filename, False)
else:
filename += "-release" + get_release_number(filename, False)
filename += ".war"
return filename
@task
def prod():
env.is_rc = False
# Setups liferay & evals dev environment
@task
def setup():
portal.liferay_dev_setup()
with lcd('~/Documents/liferay-plugins-sdk-5.2.3/portlets'):
local('git clone git@gitlab.cws.oregonstate.edu:evals.git')
with lcd('evals'):
local('git checkout develop')