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

fffff

parent 5bfa4100
......@@ -83,20 +83,43 @@ def prepare_python(systemName, contextDir) {
sh "cp -rf /home/quant_group/config_repository/python/${systemName}.ini ${contextDir}/config.ini"
}
def checkout(git_path, branchName) {
git branch: branchName, credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: git_path
def checkout(buildType,systemName, branchName) {
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_nodejs(branchName, systemName) {
git_path = project_attr(systemName)["gitPath"]
def checkout_java(gitPath, branchName) {
git branch: branchName, credentialsId: 'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db', url: gitPath
}
def checkout_nodejs(gitPth, branchName) {
currentPath = sh (
script: 'pwd',
returnStdout: true
).trim()
def folder = new File( "${currentPath}/.git/hooks" )
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'
......@@ -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 "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) {
if(gitRepo.contains("--")){
t1 = gitRepo.split("/")
def checkout_lua_ui(gitPaths, branchName) {
if(gitPaths.contains("--")){
t1 = gitPths.split("/")
groups = t1[0].split("--")
projects = t1[1].split("--")
branches = branchName.split("--")
......@@ -122,17 +145,17 @@ def checkout_lua_ui(branchName, gitRepo) {
t1.size().times {
dir (projects[it]) {
project_attr = project_attr(projects[it])
git_path = project_attr["gitPath"]
currentPath = sh (
script: 'pwd',
returnStdout: true
).trim()
projectAttr = project_attr(projects[it])
gitPath = projectAttr["gitPath"]
currentPath = sh (
script: 'pwd',
returnStdout: true
).trim()
def folder = new File( "${currentPath}/.git/hooks" )
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'
......@@ -143,7 +166,7 @@ def checkout_lua_ui(branchName, gitRepo) {
}else{
sh "\\cp -rf /home/quant_group/config_repository/lua-ui/hook/post-merge .git/hooks/"
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,18 +176,18 @@ def checkout_lua_ui(branchName, gitRepo) {
project = t1[1]
dir (project) {
project_attr = project_attr(project)
git_path = project_attr["gitPath"]
projectAttr = project_attr(project)
gitPath = projectAttr["gitPath"]
currentPath = sh (
script: 'pwd',
returnStdout: true
).trim()
currentPath = sh (
script: 'pwd',
returnStdout: true
).trim()
def folder = new File( "${currentPath}/.git/hooks" )
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'
if (bowerFile) {
......@@ -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 "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) {
sh '/usr/share/maven/bin/mvn clean package -P test -D maven.test.skip=true'
}
def copy_files(buildType,target,contextDir){
def build(buildType,systemName, contextDir){
switch(buildType){
case "java":
copy_files_java(target,contextDir)
break
default:
echo "%{buildType} not copy...."
}
case "java":
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
default:
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)
configPath = res_json["configPath"]
......@@ -211,14 +248,14 @@ def build_nodejs(namespace, systemName, 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/beta/config.ini"
sh 'tar zcf dist.tgz server/'
sh "mv dist.tgz ${contextDir}"
}
def build_luaui(namespace, systemNames, contextDir) {
def build_luaui( systemNames, contextDir) {
arrSystem = systemNames.split("--")
for (systemName in arrSystem) {
dir (systemName) {
......@@ -344,7 +381,7 @@ def getDocketPackageImage(buildType){
args +="-v /home/quant_group/config_repository:/home/quant_group/config_repository "
args +="-v /home/quant_group/pacakge/:/home/quant_group/pacakge/ "
packageImageInfo["image"] = "192.168.4.36/baseimg/jenkins-node-slave:2018040401"
packageImageInfo["args"] = ""
packageImageInfo["args"] = args
break
default:
echo ""
......
......@@ -61,20 +61,16 @@ def call(body) {
/*checkout code*/
_utils.beautyEcho("checkout", "info")
_stage.checkout(gitPath, branchName)
_stage.checkout(config.buildType, systemName, branchName)
/*prepare config*/
_utils.beautyEcho("prepare config", "info")
_stage.prepare_config(config.buildType,systemName, contextDir)
_stage.prepare_config(config.buildType, systemName, contextDir)
/*build*/
_utils.beautyEcho("build", "info")
def buildCmd = project_attr["buildCmd"]
sh "${buildCmd}"
/*copy files*/
_utils.beautyEcho("copy files", "info")
_stage.copy_files(config.buildType,project_attr["jarFilePath"],contextDir)
_stage.build(config.buildType, systemName, contextDir)
}
}
_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