Commit 7dab6b08 authored by wentao.suo's avatar wentao.suo

fffff

parent 5bfa4100
...@@ -83,20 +83,43 @@ def prepare_python(systemName, contextDir) { ...@@ -83,20 +83,43 @@ def prepare_python(systemName, contextDir) {
sh "cp -rf /home/quant_group/config_repository/python/${systemName}.ini ${contextDir}/config.ini" sh "cp -rf /home/quant_group/config_repository/python/${systemName}.ini ${contextDir}/config.ini"
} }
def checkout(git_path, branchName) { def checkout(buildType,systemName, branchName) {
git branch: branchName, credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: git_path def projectAttr = project_attr(systemName)
def gitPath =projectAttr["gitPath"]
switch(buildType){
case "java":
build_java(gitPath, branchName)
break
case "nodejs":
build_nodejs(gitPath, branchName)
break
case "python":
build_python(gitPath, branchName)
break
case "lua-ui":
build_luaui(gitPath, branchName)
break
default:
echo "未知的buildType: ${config.buildType}"
break
}
}
def checkout_java(gitPath, branchName) {
git branch: branchName, credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: gitPath
} }
def checkout_nodejs(branchName, systemName) {
git_path = project_attr(systemName)["gitPath"] def checkout_nodejs(gitPth, branchName) {
currentPath = sh ( currentPath = sh (
script: 'pwd', script: 'pwd',
returnStdout: true returnStdout: true
).trim() ).trim()
def folder = new File( "${currentPath}/.git/hooks" ) def folder = new File( "${currentPath}/.git/hooks" )
if( !folder.exists() ) { if( !folder.exists() ) {
git branch: branchName, credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: git_path git branch: branchName, credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: gitPath
def bowerFile = fileExists './bower.json' def bowerFile = fileExists './bower.json'
...@@ -108,13 +131,13 @@ def checkout_nodejs(branchName, systemName) { ...@@ -108,13 +131,13 @@ def checkout_nodejs(branchName, systemName) {
sh "cp -rf /home/quant_group/config_repository/lua-ui/hook/post-merge .git/hooks/" sh "cp -rf /home/quant_group/config_repository/lua-ui/hook/post-merge .git/hooks/"
sh "chmod +x .git/hooks/post-merge" sh "chmod +x .git/hooks/post-merge"
git branch: branchName, credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: git_path git branch: branchName, credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: gitPath
} }
} }
def checkout_lua_ui(branchName, gitRepo) { def checkout_lua_ui(gitPaths, branchName) {
if(gitRepo.contains("--")){ if(gitPaths.contains("--")){
t1 = gitRepo.split("/") t1 = gitPths.split("/")
groups = t1[0].split("--") groups = t1[0].split("--")
projects = t1[1].split("--") projects = t1[1].split("--")
branches = branchName.split("--") branches = branchName.split("--")
...@@ -122,8 +145,8 @@ def checkout_lua_ui(branchName, gitRepo) { ...@@ -122,8 +145,8 @@ def checkout_lua_ui(branchName, gitRepo) {
t1.size().times { t1.size().times {
dir (projects[it]) { dir (projects[it]) {
project_attr = project_attr(projects[it]) projectAttr = project_attr(projects[it])
git_path = project_attr["gitPath"] gitPath = projectAttr["gitPath"]
currentPath = sh ( currentPath = sh (
script: 'pwd', script: 'pwd',
...@@ -132,7 +155,7 @@ def checkout_lua_ui(branchName, gitRepo) { ...@@ -132,7 +155,7 @@ def checkout_lua_ui(branchName, gitRepo) {
def folder = new File( "${currentPath}/.git/hooks" ) def folder = new File( "${currentPath}/.git/hooks" )
if( !folder.exists() ) { if( !folder.exists() ) {
git branch: branches[it], credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: git_path git branch: branches[it], credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: gitPath
def bowerFile = fileExists './bower.json' def bowerFile = fileExists './bower.json'
...@@ -143,7 +166,7 @@ def checkout_lua_ui(branchName, gitRepo) { ...@@ -143,7 +166,7 @@ def checkout_lua_ui(branchName, gitRepo) {
}else{ }else{
sh "\\cp -rf /home/quant_group/config_repository/lua-ui/hook/post-merge .git/hooks/" sh "\\cp -rf /home/quant_group/config_repository/lua-ui/hook/post-merge .git/hooks/"
sh "chmod +x .git/hooks/post-merge" sh "chmod +x .git/hooks/post-merge"
git branch: branches[it], credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: git_path git branch: branches[it], credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: gitPath
} }
} }
} }
...@@ -153,8 +176,8 @@ def checkout_lua_ui(branchName, gitRepo) { ...@@ -153,8 +176,8 @@ def checkout_lua_ui(branchName, gitRepo) {
project = t1[1] project = t1[1]
dir (project) { dir (project) {
project_attr = project_attr(project) projectAttr = project_attr(project)
git_path = project_attr["gitPath"] gitPath = projectAttr["gitPath"]
currentPath = sh ( currentPath = sh (
script: 'pwd', script: 'pwd',
...@@ -164,7 +187,7 @@ def checkout_lua_ui(branchName, gitRepo) { ...@@ -164,7 +187,7 @@ def checkout_lua_ui(branchName, gitRepo) {
def folder = new File( "${currentPath}/.git/hooks" ) def folder = new File( "${currentPath}/.git/hooks" )
if( !folder.exists() ) { if( !folder.exists() ) {
git branch: branchName, credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: git_path git branch: branchName, credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: gitPath
def bowerFile = fileExists './bower.json' def bowerFile = fileExists './bower.json'
if (bowerFile) { if (bowerFile) {
...@@ -175,31 +198,45 @@ def checkout_lua_ui(branchName, gitRepo) { ...@@ -175,31 +198,45 @@ def checkout_lua_ui(branchName, gitRepo) {
sh "cp -rf /home/quant_group/config_repository/lua-ui/hook/post-merge .git/hooks/" sh "cp -rf /home/quant_group/config_repository/lua-ui/hook/post-merge .git/hooks/"
sh "chmod +x .git/hooks/post-merge" sh "chmod +x .git/hooks/post-merge"
git branch: branchName, credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: git_path git branch: branchName, credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: gitPath
} }
} }
} }
} }
def build_java(namespace, systemName, contextDir) { def build(buildType,systemName, contextDir){
sh '/usr/share/maven/bin/mvn clean package -P test -D maven.test.skip=true'
}
def copy_files(buildType,target,contextDir){
switch(buildType){ switch(buildType){
case "java": case "java":
copy_files_java(target,contextDir) build_java(systemName, contextDir)
break
case "nodejs":
build_nodejs( systemName, contextDir)
break
case "python":
build_python( systemName, contextDir)
break
case "lua-ui":
build_luaui( systemName, contextDir)
break break
default: default:
echo "%{buildType} not copy...." echo "未知的buildType: ${config.buildType}"
} break
} }
def copy_files_java(target,contextDir) {
sh "cp ${target}/*.jar ${contextDir}/app.jar" def build_java(systemName, contextDir) {
def res_json = project_attr(systemName)
buildCmd = res_json["buildCmd"]
jarFilePath = project_attr["jarFilePath"]
sh "${buildCmd}"
sh "cp ${jarFilePath}/*.jar ${contextDir}/app.jar"
} }
def build_nodejs(namespace, systemName, contextDir) { def build_nodejs( systemName, contextDir) {
def res_json = project_attr(systemName) def res_json = project_attr(systemName)
configPath = res_json["configPath"] configPath = res_json["configPath"]
...@@ -211,14 +248,14 @@ def build_nodejs(namespace, systemName, contextDir) { ...@@ -211,14 +248,14 @@ def build_nodejs(namespace, systemName, contextDir) {
sh "mv dist.tgz ${contextDir}" sh "mv dist.tgz ${contextDir}"
} }
def build_python(namespace, systemName, contextDir) { def build_python( systemName, contextDir) {
sh "cp -rf ${contextDir}/config.ini server/config/release/config.ini" sh "cp -rf ${contextDir}/config.ini server/config/release/config.ini"
sh "cp -rf ${contextDir}/config.ini server/config/beta/config.ini" sh "cp -rf ${contextDir}/config.ini server/config/beta/config.ini"
sh 'tar zcf dist.tgz server/' sh 'tar zcf dist.tgz server/'
sh "mv dist.tgz ${contextDir}" sh "mv dist.tgz ${contextDir}"
} }
def build_luaui(namespace, systemNames, contextDir) { def build_luaui( systemNames, contextDir) {
arrSystem = systemNames.split("--") arrSystem = systemNames.split("--")
for (systemName in arrSystem) { for (systemName in arrSystem) {
dir (systemName) { dir (systemName) {
...@@ -344,7 +381,7 @@ def getDocketPackageImage(buildType){ ...@@ -344,7 +381,7 @@ def getDocketPackageImage(buildType){
args +="-v /home/quant_group/config_repository:/home/quant_group/config_repository " args +="-v /home/quant_group/config_repository:/home/quant_group/config_repository "
args +="-v /home/quant_group/pacakge/:/home/quant_group/pacakge/ " args +="-v /home/quant_group/pacakge/:/home/quant_group/pacakge/ "
packageImageInfo["image"] = "192.168.4.36/baseimg/jenkins-node-slave:2018040401" packageImageInfo["image"] = "192.168.4.36/baseimg/jenkins-node-slave:2018040401"
packageImageInfo["args"] = "" packageImageInfo["args"] = args
break break
default: default:
echo "" echo ""
......
...@@ -61,20 +61,16 @@ def call(body) { ...@@ -61,20 +61,16 @@ def call(body) {
/*checkout code*/ /*checkout code*/
_utils.beautyEcho("checkout", "info") _utils.beautyEcho("checkout", "info")
_stage.checkout(gitPath, branchName) _stage.checkout(config.buildType, systemName, branchName)
/*prepare config*/ /*prepare config*/
_utils.beautyEcho("prepare config", "info") _utils.beautyEcho("prepare config", "info")
_stage.prepare_config(config.buildType,systemName, contextDir) _stage.prepare_config(config.buildType, systemName, contextDir)
/*build*/ /*build*/
_utils.beautyEcho("build", "info") _utils.beautyEcho("build", "info")
def buildCmd = project_attr["buildCmd"] _stage.build(config.buildType, systemName, contextDir)
sh "${buildCmd}"
/*copy files*/
_utils.beautyEcho("copy files", "info")
_stage.copy_files(config.buildType,project_attr["jarFilePath"],contextDir)
} }
} }
_utils.beautyEcho("build over", "info") _utils.beautyEcho("build over", "info")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment