Commit 08533aa3 authored by wentao.suo's avatar wentao.suo

fix

parent 85982c36
...@@ -18,12 +18,12 @@ def contextMkdir(key) { ...@@ -18,12 +18,12 @@ def contextMkdir(key) {
return contextDir return contextDir
} }
def imageTag(harborGroup,k8sSystemName,safeBranchName,timeStemp){ def imageTag(harborGroup,k8sSystemName,safeBranchName,tagName){
def imageTag4_4=[:] def imageTag4_4=[:]
/* def branchHash = sh (script: 'git log -1 --pretty=%H',returnStdout: true).trim()*/
imageTag4_4["harborHost"]="http://192.168.4.4" imageTag4_4["harborHost"]="http://192.168.4.4"
imageTag4_4["imageTag"] = "192.168.4.4/${harborGroup}/${k8sSystemName}:${safeBranchName}-${timeStemp}" imageTag4_4["imageTag"] = "192.168.4.4/${harborGroup}/${k8sSystemName}:${safeBranchName}-${tagName}"
return [ imageTag4_4 ] return [ imageTag4_4 ]
} }
...@@ -114,6 +114,11 @@ def checkout(buildType,systemName, branchName) { ...@@ -114,6 +114,11 @@ def checkout(buildType,systemName, branchName) {
echo "未知的buildType: ${cbuildType}" echo "未知的buildType: ${cbuildType}"
break break
} }
def brahHashCode = sh (script: 'git log -1 --pretty=%H',returnStdout: true).trim()
return brahHashCode
} }
def checkout_java(systemName, branchName) { def checkout_java(systemName, branchName) {
...@@ -407,7 +412,7 @@ def getDocketPackageImage(buildType,buildEnv){ ...@@ -407,7 +412,7 @@ def getDocketPackageImage(buildType,buildEnv){
def check_and_build(buildType,systemName,branchName,contextDir){ def check_and_build(buildType,systemName,branchName,contextDir){
def branchHashCode = null
def buildEnv ="" def buildEnv =""
switch(buildType){ switch(buildType){
...@@ -432,20 +437,23 @@ def check_and_build(buildType,systemName,branchName,contextDir){ ...@@ -432,20 +437,23 @@ def check_and_build(buildType,systemName,branchName,contextDir){
if (buildType in ["nodejs","lua-ui"]){ if (buildType in ["nodejs","lua-ui"]){
cpb(buildType,systemName,branchName,contextDir) branchHashCode = cpb(buildType,systemName,branchName,contextDir)
return
} else { } else {
docker.image(pacegeDockerInfo["image"]).inside(pacegeDockerInfo["args"]){ docker.image(pacegeDockerInfo["image"]).inside(pacegeDockerInfo["args"]){
cpb(buildType,systemName,branchName,contextDir) branchHashCode = cpb(buildType,systemName,branchName,contextDir)
} }
} }
return branchHashCode
} }
def cpb(buildType,systemName,branchName,contextDir){ def cpb(buildType,systemName,branchName,contextDir){
/*checkout code*/ /*checkout code*/
stage('Checkout') { stage('Checkout') {
checkout(buildType, systemName, branchName) branchHashCode = checkout(buildType, systemName, branchName)
} }
/*prepare config*/ /*prepare config*/
stage('Prepare') { stage('Prepare') {
...@@ -456,6 +464,8 @@ def cpb(buildType,systemName,branchName,contextDir){ ...@@ -456,6 +464,8 @@ def cpb(buildType,systemName,branchName,contextDir){
build(buildType, systemName, contextDir) build(buildType, systemName, contextDir)
} }
return branchHashCode
} }
def dockerbuild_and_push(imageTagInfo,buildNumber,systemName,branchName,cluster,timeStemp,contextDir){ def dockerbuild_and_push(imageTagInfo,buildNumber,systemName,branchName,cluster,timeStemp,contextDir){
......
...@@ -31,6 +31,7 @@ def call(body) { ...@@ -31,6 +31,7 @@ def call(body) {
def contextDir def contextDir
def imageTagInfos def imageTagInfos
def branchHashCode
body.resolveStrategy = Closure.DELEGATE_FIRST body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = config body.delegate = config
...@@ -59,7 +60,7 @@ def call(body) { ...@@ -59,7 +60,7 @@ def call(body) {
for(def i = 0; i<systemNames.length; i++){ for(def i = 0; i<systemNames.length; i++){
dir(systemNames[i]){ dir(systemNames[i]){
_stage.check_and_build(config.buildType, systemNames[i], branchNames[i], contextDir) branchHashCode = _stage.check_and_build(config.buildType, systemNames[i], branchNames[i], contextDir)
} }
} }
...@@ -77,7 +78,7 @@ def call(body) { ...@@ -77,7 +78,7 @@ def call(body) {
def regex = "[`,./;\\[\\]&<>?:\"()|-]+" def regex = "[`,./;\\[\\]&<>?:\"()|-]+"
def k8sSystemName = originSystemName.replaceAll("_","-") def k8sSystemName = originSystemName.replaceAll("_","-")
def safeBranchName = originBranchName.replaceAll(regex,"_") def safeBranchName = originBranchName.replaceAll(regex,"_")
imageTagInfos = _stage.imageTag(harborGroup,k8sSystemName,safeBranchName,timeStemp) imageTagInfos = _stage.imageTag(harborGroup,k8sSystemName,safeBranchName,branchHashCode)
for (imageTagInfo in imageTagInfos){ for (imageTagInfo in imageTagInfos){
......
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