Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-deploy-utils
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
qa-deploy-utils
Commits
cf53ec4e
Commit
cf53ec4e
authored
Jan 15, 2017
by
xiaolin.zhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add diff config
parent
c47f04cd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
3 deletions
+119
-3
check_file_diff.js
sh-utils/deploy/check_file_diff.js
+85
-0
java_deploy.sh
sh-utils/deploy/java_deploy.sh
+34
-3
No files found.
sh-utils/deploy/check_file_diff.js
0 → 100644
View file @
cf53ec4e
var
source_file
,
java_config_path
,
L
,
key
,
value
,
FL
var
IP_REG
=
new
RegExp
(
/
((?:(?:
25
[
0-5
]
|2
[
0-4
]\d
|
((
1
\d{2})
|
([
1-9
]?\d)))\.){3}(?:
25
[
0-5
]
|2
[
0-4
]\d
|
((
1
\d{2})
|
([
1-9
]?\d))))
/g
);
process
.
argv
.
forEach
(
function
(
val
,
index
,
array
)
{
if
(
index
==
2
){
source_file
=
val
;
}
else
{
java_config_path
=
val
;
}
});
console
.
log
(
"
本地配置文件:%s
"
,
source_file
)
console
.
log
(
"
项目配置文件:%s
"
,
java_config_path
)
function
getNowFormatDate
()
{
var
date
=
new
Date
();
var
seperator1
=
"
-
"
;
var
seperator2
=
"
:
"
;
var
month
=
date
.
getMonth
()
+
1
;
var
strDate
=
date
.
getDate
();
if
(
month
>=
1
&&
month
<=
9
)
{
month
=
"
0
"
+
month
;
}
if
(
strDate
>=
0
&&
strDate
<=
9
)
{
strDate
=
"
0
"
+
strDate
;
}
var
currentdate
=
date
.
getFullYear
()
+
seperator1
+
month
+
seperator1
+
strDate
+
"
"
+
date
.
getHours
()
+
seperator2
+
date
.
getMinutes
()
+
seperator2
+
date
.
getSeconds
();
return
currentdate
;
}
var
list_source_file_keys
=
{},
diff_list
=
[],
value_of_diff_change
;
var
java_config_data
,
java_config_data_lines
;
var
fs
=
require
(
"
fs
"
);
var
path
=
require
(
'
path
'
);
var
list_source_file_data
=
fs
.
readFileSync
(
source_file
,
'
utf-8
'
);
var
lines
=
list_source_file_data
.
split
(
"
\n
"
)
for
(
var
i
=
0
;
i
<
lines
.
length
;
++
i
)
{
L
=
lines
[
i
].
split
(
"
=
"
)
key
=
L
[
0
]
value
=
L
[
1
]
FL
=
L
[
0
].
replace
(
/
\s
/g
,
""
);
if
(
FL
[
0
]
!=
"
#
"
&&
FL
.
length
!=
0
){
list_source_file_keys
[
L
[
0
]]
=
L
[
1
];
}
}
fs
.
readdir
(
java_config_path
,
function
(
err
,
files
){
var
count
=
files
.
length
;
files
.
forEach
(
function
(
filename
){
if
(
filename
.
indexOf
(
"
.properties
"
)
!=
-
1
){
var
java_config_data
=
fs
.
readFileSync
(
path
.
join
(
java_config_path
,
filename
),
'
utf-8
'
);
var
java_config_data_lines
=
java_config_data
.
split
(
"
\n
"
)
for
(
var
i
=
0
;
i
<
java_config_data_lines
.
length
;
++
i
)
{
L
=
java_config_data_lines
[
i
].
split
(
"
=
"
)
key
=
L
[
0
]
value
=
L
[
1
]
FL
=
L
[
0
].
replace
(
/
\s
/g
,
""
);
if
(
FL
[
0
]
!=
"
#
"
&&
FL
.
length
!=
0
){
if
(
typeof
list_source_file_keys
[
L
[
0
]]
==
"
undefined
"
){
console
.
log
(
"
Warning!!!:
\"
%s
\"\t
"
,
L
[
0
]);
diff_list
.
push
({
name
:
L
[
0
],
value
:
L
[
1
]})
}
}
}
}
})
if
(
diff_list
.
length
>
0
){
fs
.
appendFile
(
source_file
,
"
#时间:
"
+
getNowFormatDate
()
+
"
,差异追加如下:
\n
"
);
}
for
(
var
i
=
0
;
i
<
diff_list
.
length
;
++
i
){
if
(
IP_REG
.
test
(
diff_list
[
i
].
value
))
{
IP_REG
.
lastIndex
=
0
;
fs
.
appendFile
(
source_file
,
"
#
"
+
diff_list
[
i
].
name
+
"
=
"
+
diff_list
[
i
].
value
+
"
\n
"
);
value_of_diff_change
=
diff_list
[
i
].
value
.
replace
(
/
((?:(?:
25
[
0-5
]
|2
[
0-4
]\d
|
((
1
\d{2})
|
([
1-9
]?\d)))\.){3}(?:
25
[
0-5
]
|2
[
0-4
]\d
|
((
1
\d{2})
|
([
1-9
]?\d))))
/g
,
"
localhost
"
)
fs
.
appendFile
(
source_file
,
diff_list
[
i
].
name
+
"
=
"
+
value_of_diff_change
+
"
\n
"
);
}
else
{
fs
.
appendFile
(
source_file
,
diff_list
[
i
].
name
+
"
=
"
+
diff_list
[
i
].
value
+
"
\n
"
);
}
}
})
sh-utils/deploy/java_deploy.sh
View file @
cf53ec4e
...
...
@@ -34,23 +34,54 @@ else
echo
"Step 1: skip checkout branch:
$branch_name
"
fi
# 增加文件差异对比 2017-01-15 田亚伟
echo
"Step 1.1: checkout properties files: "
config_path
=
`
pwd
`
expect
-c
"
spawn scp root@
${
host
}
:/home/quant_group/
${
module
}
/*.properties ./
expect {
\"
*assword
\"
{
send
\"
!QAZ2wsx
\n\"
}
}
expect eof"
echo
"------------------------config_fidd:begin------------------------------"
echo
`
node
${
utils_path
}
/sh-utils/deploy/check_file_diff.js
${
config_path
}
/application.properties /home/quant_group/jenkins/workspace/deploy_
${
module
}
/src/main/resources/config/test/
`
sed
$(
echo
-e
"s/
\r
//"
)
application.properties
>
application_last.properties
echo
`
pwd
`
expect
-c
"
spawn scp
${
config_path
}
/application_last.properties root@
${
host
}
:/home/quant_group/
${
module
}
/application.properties
expect {
\"
*assword
\"
{
send
\"
!QAZ2wsx
\n\"
}
}
expect eof"
echo
"-------------------------config_fidd:end-------------------------------"
# 增加文件差异对比 结束2017-01-15 田亚伟
if
[
"
$build_java
"
=
true
]
;
then
echo
"Step 2: build project:
$branch_name
"
sh
${
utils_path
}
/sh-utils/center/2_build_java.sh
$profile
$module
$host
$close_captcha
#
sh ${utils_path}/sh-utils/center/2_build_java.sh $profile $module $host $close_captcha
else
echo
"Step 2: skip build project:
$branch_name
"
fi
if
[
"
$remote_copy
"
=
true
]
;
then
echo
"Step 3: remote copy project: "
sh
${
utils_path
}
/sh-utils/center/3_remote_copy.sh
$module
$host
java
#
sh ${utils_path}/sh-utils/center/3_remote_copy.sh $module $host java
else
echo
"Step 3: skip remote copy project"
fi
if
[
"
$restart_java
"
=
true
]
;
then
echo
"Step 4: restart project: "
sh
${
utils_path
}
/sh-utils/center/4_java_restart.sh
$module
$host
"
${
re_load_config
}
"
"
${
use_pulic_ip
}
"
#
sh ${utils_path}/sh-utils/center/4_java_restart.sh $module $host "${re_load_config}" "${use_pulic_ip}"
else
echo
"Step 4: skip restart project"
fi
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment