Commit 8668b249 authored by wentao.suo's avatar wentao.suo

ff

parent 5422692a
...@@ -34,7 +34,7 @@ def call(body) { ...@@ -34,7 +34,7 @@ def call(body) {
def contextDir def contextDir
def _stage = new org.qg.docker.StageBucket() def _stage = new org.qg.docker.StageBucket()
def _utils = new org.qg.docker.Utils() def _utils = new org.qg.docker.Utils()
def contextDir = "tmp-context"
body.resolveStrategy = Closure.DELEGATE_FIRST body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = config body.delegate = config
body() body()
...@@ -55,6 +55,13 @@ def call(body) { ...@@ -55,6 +55,13 @@ def call(body) {
sh 'mvn clean package -P test -D maven.test.skip=true' sh 'mvn clean package -P test -D maven.test.skip=true'
sh "cp target/*.jar ${contextDir}/"
dockerbuild_and_push(buildNumber,branchName,harborGroup,systemName, contextDir)
sleep 120 sleep 120
}catch (err) { }catch (err) {
sleep 120 sleep 120
...@@ -76,6 +83,33 @@ def call(body) { ...@@ -76,6 +83,33 @@ def call(body) {
} }
def dockerbuild_and_push( buildNumber, branchName, harborGroup, systemName, contextDir) {
regex = "[`,./;\\[\\]&<>?:\"()|-]+"
k8sSystemName = systemName.replaceAll("_","-")
safeBranchName = branchName.replaceAll(regex,"_")
defaultSystemName = "project"
timeStemp = new Date().format("yyyyMMddHHmmss")
imageTag = "192.168.4.36/${harborGroup}/${k8sSystemName}:${safeBranchName}-${timeStemp}"
withDockerServer([uri: "tcp://192.168.4.96:2375/"]) {
withDockerRegistry([credentialsId: 'harbor-qajenkins', url: "http://192.168.4.36"]) {
def image = docker.build(imageTag, "--build-arg BUILD_TIME=${timeNow} --build-arg BUILD_NUMBER=${buildNumber} --build-arg SYSTEM_NAME=${systemName} --build-arg BRANCH_NAME=${branchName} --build-arg SAFE_SYSTEM_NAME=${defaultSystemName} ${contextDir}")
image.push()
if (branchName == "master" || branchName == "master--master") {
image.push('latest')
}
}
}
_utils().beautyEcho("镜像地址:${imageTag}", "info")
return imageTag
}
@NonCPS @NonCPS
def jsonParse(def json) { def jsonParse(def json) {
new groovy.json.JsonSlurperClassic().parseText(json) new groovy.json.JsonSlurperClassic().parseText(json)
......
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