Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
global-jenkinsfile
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
global-jenkinsfile
Commits
00247c2c
Commit
00247c2c
authored
May 31, 2019
by
kewei.jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发送 执行ID
parent
130d7035
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
97 deletions
+111
-97
StageBucketTke.groovy
src/org/qg/docker_new/StageBucketTke.groovy
+89
-77
qgDockerPiplineWithDockerSlaveTke.groovy
vars/qgDockerPiplineWithDockerSlaveTke.groovy
+22
-20
No files found.
src/org/qg/docker_new/StageBucketTke.groovy
View file @
00247c2c
...
@@ -3,7 +3,7 @@ package org.qg.docker_new;
...
@@ -3,7 +3,7 @@ package org.qg.docker_new;
import
org.qg.docker_new.Utils
;
import
org.qg.docker_new.Utils
;
import
groovy.json.JsonSlurperClassic
;
import
groovy.json.JsonSlurperClassic
;
def
_utils
()
{
def
_utils
()
{
return
new
org
.
qg
.
docker_new
.
Utils
();
return
new
org
.
qg
.
docker_new
.
Utils
();
}
}
...
@@ -19,14 +19,14 @@ def contextMkdir(key) {
...
@@ -19,14 +19,14 @@ def contextMkdir(key) {
}
}
def
imageTag
(
harborGroup
,
k8sSystemName
,
safeBranchName
,
tagName
){
def
imageTag
(
harborGroup
,
k8sSystemName
,
safeBranchName
,
tagName
){
def
imageTag4_4
=[:]
def
imageTag4_4
=[:]
imageTag4_4
[
"harborHost"
]=
"http://192.168.4.4"
imageTag4_4
[
"harborHost"
]=
"http://192.168.4.4"
imageTag4_4
[
"imageTag"
]
=
"${harborGroup}/${k8sSystemName}:${safeBranchName}-${tagName}"
imageTag4_4
[
"imageTag"
]
=
"${harborGroup}/${k8sSystemName}:${safeBranchName}-${tagName}"
imageTag4_4
[
"imageTagCode"
]
=
"${harborGroup}/${k8sSystemName}:Code${safeBranchName}-${tagName}"
imageTag4_4
[
"imageTagCode"
]
=
"${harborGroup}/${k8sSystemName}:Code${safeBranchName}-${tagName}"
return
[
imageTag4_4
]
return
[
imageTag4_4
]
}
}
def
init_dependency
()
{
def
init_dependency
()
{
sh
"cd /home/quant_group/qg-dockerfiles; git pull; cd -"
sh
"cd /home/quant_group/qg-dockerfiles; git pull; cd -"
sh
"cd /home/quant_group/config_repository; git pull origin master; cd -"
sh
"cd /home/quant_group/config_repository; git pull origin master; cd -"
}
}
...
@@ -35,7 +35,7 @@ def init_image_dependency(buildType,originSystemName,contextDir){
...
@@ -35,7 +35,7 @@ def init_image_dependency(buildType,originSystemName,contextDir){
switch
(
buildType
){
switch
(
buildType
){
case
"lua-ui"
:
case
"lua-ui"
:
sh
"cp -rf /home/quant_group/qg-dockerfiles/tke/ui/* ${contextDir}"
sh
"cp -rf /home/quant_group/qg-dockerfiles/tke/ui/* ${contextDir}"
def
isVhFileExist
=
fileExists
"/home/quant_group/config_repository/lua-ui/nginx/${originSystemName}.vh.conf"
def
isVhFileExist
=
fileExists
"/home/quant_group/config_repository/lua-ui/nginx/${originSystemName}.vh.conf"
if
(
isVhFileExist
)
{
if
(
isVhFileExist
)
{
sh
"cp -rf /home/quant_group/config_repository/lua-ui/nginx/${originSystemName}.vh.conf ${contextDir}"
sh
"cp -rf /home/quant_group/config_repository/lua-ui/nginx/${originSystemName}.vh.conf ${contextDir}"
...
@@ -43,7 +43,7 @@ def init_image_dependency(buildType,originSystemName,contextDir){
...
@@ -43,7 +43,7 @@ def init_image_dependency(buildType,originSystemName,contextDir){
sh
"cp -rf /home/quant_group/config_repository/lua-ui/nginx/default.vh.conf ${contextDir}"
sh
"cp -rf /home/quant_group/config_repository/lua-ui/nginx/default.vh.conf ${contextDir}"
}
}
break
break
default:
default:
break
break
}
}
}
}
...
@@ -81,7 +81,7 @@ def update_microservice(namespace, name, image, tier, domain) {
...
@@ -81,7 +81,7 @@ def update_microservice(namespace, name, image, tier, domain) {
response
=
httpRequest
httpMode:
"POST"
,
response
=
httpRequest
httpMode:
"POST"
,
consoleLogResponseBody:
true
,
consoleLogResponseBody:
true
,
contentType:
"APPLICATION_JSON"
,
contentType:
"APPLICATION_JSON"
,
requestBody:
"""{
requestBody:
"""{
"namespace":"${namespace}",
"namespace":"${namespace}",
"serviceName":"${name}",
"serviceName":"${name}",
...
@@ -92,38 +92,50 @@ def update_microservice(namespace, name, image, tier, domain) {
...
@@ -92,38 +92,50 @@ def update_microservice(namespace, name, image, tier, domain) {
"debug":0
"debug":0
}"""
,
}"""
,
url:
dest_url
url:
dest_url
def
res_json
=
jsonParse
(
response
.
content
)
def
res_json
=
jsonParse
(
response
.
content
)
return
res_json
return
res_json
}
}
def
ding_talk
(
buildNumber
,
flag
)
{
dest_url
=
"http://192.168.29.80:3003/pipeline/dingTalk"
response
=
httpRequest
httpMode:
"POST"
,
consoleLogResponseBody:
true
,
contentType:
"APPLICATION_JSON"
,
requestBody:
"""{
"buildNumber":"${buildNumber}",
"flag":"${flag}",
}"""
,
url:
dest_url
}
def
set_image_info
(
microservice_name
,
git_commit_hash
,
image
)
{
def
set_image_info
(
microservice_name
,
git_commit_hash
,
image
)
{
dest_url
=
"http://eos.quantgroups.com/api/etcd/set_image_info"
dest_url
=
"http://eos.quantgroups.com/api/etcd/set_image_info"
response
=
httpRequest
httpMode:
"POST"
,
response
=
httpRequest
httpMode:
"POST"
,
consoleLogResponseBody:
true
,
consoleLogResponseBody:
true
,
contentType:
"APPLICATION_JSON"
,
contentType:
"APPLICATION_JSON"
,
requestBody:
"""{
requestBody:
"""{
"microservice_name":"${microservice_name}",
"microservice_name":"${microservice_name}",
"git_commit_hash":"${git_commit_hash}",
"git_commit_hash":"${git_commit_hash}",
"image": "${image}"
"image": "${image}"
}"""
,
}"""
,
url:
dest_url
url:
dest_url
def
res_json
=
jsonParse
(
response
.
content
)
def
res_json
=
jsonParse
(
response
.
content
)
return
res_json
return
res_json
}
}
def
slaveImageRespority
(
buildEnv
){
def
slaveImageRespority
(
buildEnv
){
//envType java8 java9 node7 node8
//envType java8 java9 node7 node8
switch
(
buildEnv
){
switch
(
buildEnv
){
case
"java8"
:
case
"java8"
:
// return "192.168.4.4/baseimg/jenkins-java-slave:latest"
// return "192.168.4.4/baseimg/jenkins-java-slave:latest"
return
"192.168.4.4/baseimg/jenkins-java-slave-new:latest"
return
"192.168.4.4/baseimg/jenkins-java-slave-new:latest"
break
break
case
"java9"
:
case
"java9"
:
return
null
return
null
break
break
case
"node7"
:
case
"node7"
:
return
"192.168.4.4/baseimg/jenkins-node7-slave:latest"
return
"192.168.4.4/baseimg/jenkins-node7-slave:latest"
...
@@ -143,49 +155,49 @@ def slaveImageArgs(buildType){
...
@@ -143,49 +155,49 @@ def slaveImageArgs(buildType){
args
+=
"-v /home/quant_group/package/:/home/quant_group/package/ "
args
+=
"-v /home/quant_group/package/:/home/quant_group/package/ "
switch
(
buildType
)
{
switch
(
buildType
)
{
case
"java"
:
case
"java"
:
args
+=
"-v /root/.m2:/root/.m2 "
args
+=
"-v /root/.m2:/root/.m2 "
break
break
case
"nodejs"
:
case
"nodejs"
:
args
+=
"-v /root/.nvm/versions/node/v8.9.1/bin:/usr/local/node-v8.9.1-linux-x64/bin "
args
+=
"-v /root/.nvm/versions/node/v8.9.1/bin:/usr/local/node-v8.9.1-linux-x64/bin "
args
+=
"-v /root/.npm:/root/.npm:rw "
args
+=
"-v /root/.npm:/root/.npm:rw "
args
+=
"-v /root/.cache:/root/.cache:rw "
args
+=
"-v /root/.cache:/root/.cache:rw "
args
+=
"-v /root/.node-gyp:/root/.node-gyp:rw "
args
+=
"-v /root/.node-gyp:/root/.node-gyp:rw "
break
break
case
"python"
:
case
"python"
:
break
break
case
"lua-ui"
:
case
"lua-ui"
:
args
+=
"-v /root/.nvm/versions/node/v8.9.1/bin:/usr/local/node-v8.9.1-linux-x64/bin "
args
+=
"-v /root/.nvm/versions/node/v8.9.1/bin:/usr/local/node-v8.9.1-linux-x64/bin "
args
+=
"-v /root/.npm:/root/.npm:rw "
args
+=
"-v /root/.npm:/root/.npm:rw "
args
+=
"-v /root/.cache:/root/.cache:rw "
args
+=
"-v /root/.cache:/root/.cache:rw "
args
+=
"-v /root/.node-gyp:/root/.node-gyp:rw "
args
+=
"-v /root/.node-gyp:/root/.node-gyp:rw "
break
break
default:
default:
break
break
}
}
return
args
return
args
}
}
def
getDocketPackageImage
(
buildType
,
buildEnv
){
def
getDocketPackageImage
(
buildType
,
buildEnv
){
echo
"getDocketPackageImage :${buildType}"
echo
"getDocketPackageImage :${buildType}"
def
packageImageInfo
=[:]
def
packageImageInfo
=[:]
packageImageInfo
[
"image"
]
=
slaveImageRespority
(
buildEnv
)
packageImageInfo
[
"image"
]
=
slaveImageRespority
(
buildEnv
)
packageImageInfo
[
"args"
]
=
slaveImageArgs
(
buildType
)
packageImageInfo
[
"args"
]
=
slaveImageArgs
(
buildType
)
_utils
().
beautyEcho
(
"image :"
+
packageImageInfo
[
"image"
],
"info"
)
_utils
().
beautyEcho
(
"image :"
+
packageImageInfo
[
"image"
],
"info"
)
_utils
().
beautyEcho
(
"args :"
+
packageImageInfo
[
"args"
],
"info"
)
_utils
().
beautyEcho
(
"args :"
+
packageImageInfo
[
"args"
],
"info"
)
return
packageImageInfo
return
packageImageInfo
}
}
def
check_and_build
(
buildType
,
systemName
,
branchName
,
contextDir
){
def
check_and_build
(
buildType
,
systemName
,
branchName
,
contextDir
){
def
branchHashCode
=
null
def
branchHashCode
=
null
def
buildEnv
=
""
def
buildEnv
=
""
switch
(
buildType
){
switch
(
buildType
){
case
"java"
:
case
"java"
:
...
@@ -198,28 +210,28 @@ def check_and_build(buildType,systemName,branchName,contextDir){
...
@@ -198,28 +210,28 @@ def check_and_build(buildType,systemName,branchName,contextDir){
}
}
break
break
case
"nodejs"
:
case
"nodejs"
:
buildEnv
=
"node8"
buildEnv
=
"node8"
break
break
default
:
default
:
buildEnv
=
"java8"
buildEnv
=
"java8"
}
}
def
pacegeDockerInfo
=
getDocketPackageImage
(
buildType
,
buildEnv
)
def
pacegeDockerInfo
=
getDocketPackageImage
(
buildType
,
buildEnv
)
if
(
buildType
in
[
"nodejs"
,
"lua-ui"
]){
if
(
buildType
in
[
"nodejs"
,
"lua-ui"
]){
branchHashCode
=
cpb
(
buildType
,
systemName
,
branchName
,
contextDir
)
branchHashCode
=
cpb
(
buildType
,
systemName
,
branchName
,
contextDir
)
}
else
{
}
else
{
docker
.
image
(
pacegeDockerInfo
[
"image"
]).
inside
(
pacegeDockerInfo
[
"args"
]){
docker
.
image
(
pacegeDockerInfo
[
"image"
]).
inside
(
pacegeDockerInfo
[
"args"
]){
branchHashCode
=
cpb
(
buildType
,
systemName
,
branchName
,
contextDir
)
branchHashCode
=
cpb
(
buildType
,
systemName
,
branchName
,
contextDir
)
}
}
}
}
return
branchHashCode
return
branchHashCode
}
}
def
cpb
(
buildType
,
systemName
,
branchName
,
contextDir
){
def
cpb
(
buildType
,
systemName
,
branchName
,
contextDir
){
/*checkout code*/
/*checkout code*/
stage
(
'Checkout'
)
{
stage
(
'Checkout'
)
{
branchHashCode
=
checkout
(
buildType
,
systemName
,
branchName
)
branchHashCode
=
checkout
(
buildType
,
systemName
,
branchName
)
}
}
...
@@ -244,7 +256,7 @@ def checkout(buildType,systemName, branchName) {
...
@@ -244,7 +256,7 @@ def checkout(buildType,systemName, branchName) {
switch
(
buildType
){
switch
(
buildType
){
case
"java"
:
case
"java"
:
checkout_java
(
systemName
,
branchName
)
checkout_java
(
systemName
,
branchName
)
break
break
case
"nodejs"
:
case
"nodejs"
:
checkout_nodejs
(
systemName
,
branchName
)
checkout_nodejs
(
systemName
,
branchName
)
break
break
...
@@ -253,17 +265,17 @@ def checkout(buildType,systemName, branchName) {
...
@@ -253,17 +265,17 @@ def checkout(buildType,systemName, branchName) {
break
break
case
"lua-ui"
:
case
"lua-ui"
:
checkout_luaui
(
systemName
,
branchName
)
checkout_luaui
(
systemName
,
branchName
)
break
break
default:
default:
echo
"未知的buildType: ${buildType}"
echo
"未知的buildType: ${buildType}"
break
break
}
}
def
brahHashCode
=
sh
(
script:
'git log -1 --pretty=%H'
,
returnStdout:
true
).
trim
()
def
brahHashCode
=
sh
(
script:
'git log -1 --pretty=%H'
,
returnStdout:
true
).
trim
()
brahHashCode
=
brahHashCode
.
substring
(
0
,
16
)
brahHashCode
=
brahHashCode
.
substring
(
0
,
16
)
echo
"brahHashCode:${brahHashCode} with 'git log -1 --pretty=%H'"
echo
"brahHashCode:${brahHashCode} with 'git log -1 --pretty=%H'"
return
brahHashCode
return
brahHashCode
}
}
def
checkout_java
(
systemName
,
branchName
)
{
def
checkout_java
(
systemName
,
branchName
)
{
...
@@ -281,13 +293,13 @@ def checkout_python(systemName, branchName) {
...
@@ -281,13 +293,13 @@ def checkout_python(systemName, branchName) {
def
checkout_nodejs
(
systemName
,
branchName
)
{
def
checkout_nodejs
(
systemName
,
branchName
)
{
sh
"cp -rf /home/quant_group/qg-dockerfiles/tke/ui/npmrc/common-npmrc /root/.npmrc"
sh
"cp -rf /home/quant_group/qg-dockerfiles/tke/ui/npmrc/common-npmrc /root/.npmrc"
def
projectAttr
=
project_attr
(
systemName
)
def
projectAttr
=
project_attr
(
systemName
)
def
gitPath
=
projectAttr
[
"gitPath"
]
def
gitPath
=
projectAttr
[
"gitPath"
]
currentPath
=
sh
(
script:
'pwd'
,
returnStdout:
true
).
trim
()
currentPath
=
sh
(
script:
'pwd'
,
returnStdout:
true
).
trim
()
def
folder
=
new
File
(
"${currentPath}/.git/hooks"
)
def
folder
=
new
File
(
"${currentPath}/.git/hooks"
)
echo
"${currentPath}/.git/hooks"
echo
"${currentPath}/.git/hooks"
if
(
!
folder
.
exists
()){
if
(
!
folder
.
exists
()){
echo
">>>>>>>>> first git clone"
echo
">>>>>>>>> first git clone"
git
branch:
branchName
,
credentialsId:
'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db'
,
url:
gitPath
git
branch:
branchName
,
credentialsId:
'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db'
,
url:
gitPath
...
@@ -295,47 +307,47 @@ def checkout_nodejs(systemName, branchName) {
...
@@ -295,47 +307,47 @@ def checkout_nodejs(systemName, branchName) {
if
(
bowerFile
)
{
if
(
bowerFile
)
{
sh
"bower install --allow-root"
sh
"bower install --allow-root"
}
}
}
else
{
}
else
{
echo
">>>>>>>>> not first git clone"
echo
">>>>>>>>> not first git clone"
// sh "cp -rf /home/quant_group/config_repository/lua-ui/hook/post-checkout .git/hooks/"
// sh "cp -rf /home/quant_group/config_repository/lua-ui/hook/post-checkout .git/hooks/"
// sh "chmod +x .git/hooks/post-checkout"
// sh "chmod +x .git/hooks/post-checkout"
git
branch:
branchName
,
credentialsId:
'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db'
,
url:
gitPath
git
branch:
branchName
,
credentialsId:
'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db'
,
url:
gitPath
}
}
// sh "npm install"
// sh "npm install"
}
}
def
checkout_luaui
(
systemName
,
branchName
)
{
def
checkout_luaui
(
systemName
,
branchName
)
{
currentPath
=
sh
(
script:
'pwd'
,
returnStdout:
true
).
trim
()
currentPath
=
sh
(
script:
'pwd'
,
returnStdout:
true
).
trim
()
echo
"- ${currentPath} -"
echo
"- ${currentPath} -"
sh
"whoami"
sh
"whoami"
echo
"----------------------------"
echo
"----------------------------"
// def npmrcPath = "/home/quant_group/config_repository/lua-ui/npmrc/${systemName}-npmrc"
// def npmrcPath = "/home/quant_group/config_repository/lua-ui/npmrc/${systemName}-npmrc"
// def specialNpmrc = new File( npmrcPath )
// def specialNpmrc = new File( npmrcPath )
// if(specialNpmrc.exists()){
// if(specialNpmrc.exists()){
// sh "cp -rf ${npmrcPath} .npmrc"
// sh "cp -rf ${npmrcPath} .npmrc"
// }
// }
_utils
().
beautyEcho
(
"ui project : ${systemName}"
,
"info"
)
_utils
().
beautyEcho
(
"ui project : ${systemName}"
,
"info"
)
projectAttr
=
project_attr
(
systemName
)
projectAttr
=
project_attr
(
systemName
)
gitPath
=
projectAttr
[
"gitPath"
]
gitPath
=
projectAttr
[
"gitPath"
]
//0 if project is simple ui not run npm install
//0 if project is simple ui not run npm install
def
hookfolder
=
new
File
(
"${currentPath}/.git/hooks"
)
def
hookfolder
=
new
File
(
"${currentPath}/.git/hooks"
)
def
packejson
=
new
File
(
"${currentPath}/package.json"
)
def
packejson
=
new
File
(
"${currentPath}/package.json"
)
sh
"cp -rf /home/quant_group/qg-dockerfiles/tke/ui/npmrc/common-npmrc /root/.npmrc"
sh
"cp -rf /home/quant_group/qg-dockerfiles/tke/ui/npmrc/common-npmrc /root/.npmrc"
if
(!
hookfolder
.
exists
()){
if
(!
hookfolder
.
exists
()){
echo
">>>>>>> first checkout project ${systemName}"
echo
">>>>>>> first checkout project ${systemName}"
git
branch:
branchName
,
credentialsId:
'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db'
,
url:
gitPath
git
branch:
branchName
,
credentialsId:
'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db'
,
url:
gitPath
def
bowerResult
=
ext_bower_install
()
def
bowerResult
=
ext_bower_install
()
def
npmResult
=
ext_npm_intall
()
def
npmResult
=
ext_npm_intall
()
def
resultNum
=
bowerResult
+
npmResult
def
resultNum
=
bowerResult
+
npmResult
if
(
resultNum
==
0
){
if
(
resultNum
==
0
){
echo
">>>>>>> is simple ui project"
echo
">>>>>>> is simple ui project"
def
dist
=
fileExists
'./dist'
def
dist
=
fileExists
'./dist'
...
@@ -346,12 +358,12 @@ def checkout_luaui(systemName, branchName) {
...
@@ -346,12 +358,12 @@ def checkout_luaui(systemName, branchName) {
}
else
{
}
else
{
echo
">>>>>>> is node ui project"
echo
">>>>>>> is node ui project"
def
bowerFile
=
fileExists
'./bower.json'
def
bowerFile
=
fileExists
'./bower.json'
sh
"npm install"
sh
"npm install"
if
(
bowerFile
)
{
if
(
bowerFile
)
{
sh
"bower install --allow-root"
sh
"bower install --allow-root"
}
}
}
}
}
else
{
}
else
{
if
(!
packejson
.
exists
()){
if
(!
packejson
.
exists
()){
echo
">>>>>>> is simple ui project"
echo
">>>>>>> is simple ui project"
...
@@ -365,11 +377,11 @@ def checkout_luaui(systemName, branchName) {
...
@@ -365,11 +377,11 @@ def checkout_luaui(systemName, branchName) {
echo
">>>>>>> is node ui project"
echo
">>>>>>> is node ui project"
// sh "cp -rf /home/quant_group/config_repository/lua-ui/hook/post-checkout .git/hooks/"
// sh "cp -rf /home/quant_group/config_repository/lua-ui/hook/post-checkout .git/hooks/"
// sh "chmod +x .git/hooks/post-checkout"
// sh "chmod +x .git/hooks/post-checkout"
git
branch:
branchName
,
credentialsId:
'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db'
,
url:
gitPath
git
branch:
branchName
,
credentialsId:
'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db'
,
url:
gitPath
sh
"npm install"
sh
"npm install"
}
}
}
}
}
}
def
prepare_config
(
buildType
,
systemName
,
contextDir
)
{
def
prepare_config
(
buildType
,
systemName
,
contextDir
)
{
...
@@ -395,9 +407,9 @@ def prepare_config(buildType,systemName, contextDir) {
...
@@ -395,9 +407,9 @@ def prepare_config(buildType,systemName, contextDir) {
def
prepare_java
(
systemName
,
contextDir
)
{
def
prepare_java
(
systemName
,
contextDir
)
{
sh
"cp -rf /home/quant_group/qg-dockerfiles/tke/java/* ${contextDir}"
sh
"cp -rf /home/quant_group/qg-dockerfiles/tke/java/* ${contextDir}"
def
existProperties
=
fileExists
"/home/quant_group/config_repository/tke/java/${systemName}.properties"
def
existProperties
=
fileExists
"/home/quant_group/config_repository/tke/java/${systemName}.properties"
echo
"------ java properties exist :$existProperties ------"
echo
"------ java properties exist :$existProperties ------"
if
(
existProperties
){
if
(
existProperties
){
sh
"cp -rf /home/quant_group/config_repository/tke/java/${systemName}.properties ${contextDir}/application.properties"
sh
"cp -rf /home/quant_group/config_repository/tke/java/${systemName}.properties ${contextDir}/application.properties"
...
@@ -413,7 +425,7 @@ def prepare_nodejs(systemName, contextDir) {
...
@@ -413,7 +425,7 @@ def prepare_nodejs(systemName, contextDir) {
// sh "cp -rf /home/quant_group/qg-dockerfiles/tke/ui/npmrc/common-npmrc /root/.npmrc"
// sh "cp -rf /home/quant_group/qg-dockerfiles/tke/ui/npmrc/common-npmrc /root/.npmrc"
}
}
def
prepare_luaui
(
systemName
,
contextDir
)
{
def
prepare_luaui
(
systemName
,
contextDir
)
{
sh
"cp -rf /home/quant_group/qg-dockerfiles/tke/ui/npmrc/common-npmrc /root/.npmrc"
sh
"cp -rf /home/quant_group/qg-dockerfiles/tke/ui/npmrc/common-npmrc /root/.npmrc"
}
}
...
@@ -429,7 +441,7 @@ def build(buildType,systemName, branchName,contextDir){
...
@@ -429,7 +441,7 @@ def build(buildType,systemName, branchName,contextDir){
switch
(
buildType
){
switch
(
buildType
){
case
"java"
:
case
"java"
:
build_java
(
systemName
,
branchName
,
contextDir
)
build_java
(
systemName
,
branchName
,
contextDir
)
break
break
case
"nodejs"
:
case
"nodejs"
:
sh
"which node"
sh
"which node"
sh
"node -v"
sh
"node -v"
...
@@ -444,31 +456,31 @@ def build(buildType,systemName, branchName,contextDir){
...
@@ -444,31 +456,31 @@ def build(buildType,systemName, branchName,contextDir){
sh
"node -v"
sh
"node -v"
sh
"npm -v"
sh
"npm -v"
build_luaui
(
systemName
,
branchName
,
contextDir
)
build_luaui
(
systemName
,
branchName
,
contextDir
)
break
break
default:
default:
echo
"未知的buildType: ${buildType}"
echo
"未知的buildType: ${buildType}"
break
break
}
}
}
}
def
build_java
(
systemName
,
branchName
,
contextDir
)
{
def
build_java
(
systemName
,
branchName
,
contextDir
)
{
def
projectAttr
=
project_attr
(
systemName
)
def
projectAttr
=
project_attr
(
systemName
)
buildCmd
=
projectAttr
[
"buildCmd"
]
buildCmd
=
projectAttr
[
"buildCmd"
]
jarFilePath
=
projectAttr
[
"jarFilePath"
]
jarFilePath
=
projectAttr
[
"jarFilePath"
]
sh
"mkdir ${contextDir}/lib ${contextDir}/config;touch ${contextDir}/lib/lib.txt;touch ${contextDir}/config/config.txt"
sh
"mkdir ${contextDir}/lib ${contextDir}/config;touch ${contextDir}/lib/lib.txt;touch ${contextDir}/config/config.txt"
sh
'mvn -v'
sh
'mvn -v'
sh
buildCmd
sh
buildCmd
sh
"mv ${jarFilePath}/*.jar ${contextDir}/app.jar"
sh
"mv ${jarFilePath}/*.jar ${contextDir}/app.jar"
currentPath
=
sh
(
script:
'pwd'
,
returnStdout:
true
).
trim
()
currentPath
=
sh
(
script:
'pwd'
,
returnStdout:
true
).
trim
()
def
libfolder
=
new
File
(
"${currentPath}/target/lib"
)
def
libfolder
=
new
File
(
"${currentPath}/target/lib"
)
echo
"${currentPath}/target/lib is exist : ${libfolder.exists()}"
echo
"${currentPath}/target/lib is exist : ${libfolder.exists()}"
if
(
libfolder
.
exists
()){
if
(
libfolder
.
exists
()){
sh
"mv ${jarFilePath}/lib/* ${contextDir}/lib"
sh
"mv ${jarFilePath}/lib/* ${contextDir}/lib"
}
}
def
configfolder
=
new
File
(
"${currentPath}/target/config"
)
def
configfolder
=
new
File
(
"${currentPath}/target/config"
)
echo
"${currentPath}/target/config is exist : ${configfolder.exists()}"
echo
"${currentPath}/target/config is exist : ${configfolder.exists()}"
if
(
configfolder
.
exists
()){
if
(
configfolder
.
exists
()){
...
@@ -476,13 +488,13 @@ def build_java(systemName, branchName,contextDir) {
...
@@ -476,13 +488,13 @@ def build_java(systemName, branchName,contextDir) {
}
}
}
}
def
build_nodejs
(
systemName
,
branchName
,
contextDir
)
{
def
build_nodejs
(
systemName
,
branchName
,
contextDir
)
{
def
projectAttr
=
project_attr
(
systemName
)
def
projectAttr
=
project_attr
(
systemName
)
configPath
=
projectAttr
[
"configPath"
]
configPath
=
projectAttr
[
"configPath"
]
buildCmd
=
projectAttr
[
"buildCmd"
]
buildCmd
=
projectAttr
[
"buildCmd"
]
configName
=
systemName
configName
=
systemName
sh
"mv -f ./${systemName}.env.config ${configPath}"
sh
"mv -f ./${systemName}.env.config ${configPath}"
sh
"tar zcf ${contextDir}/dist.tgz ./* "
sh
"tar zcf ${contextDir}/dist.tgz ./* "
sh
"cp -rf package.json ${contextDir}"
sh
"cp -rf package.json ${contextDir}"
...
@@ -492,31 +504,31 @@ def build_nodejs( systemName, branchName,contextDir) {
...
@@ -492,31 +504,31 @@ def build_nodejs( systemName, branchName,contextDir) {
def
build_python
(
systemName
,
branchName
,
contextDir
)
{
def
build_python
(
systemName
,
branchName
,
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"
def
projectAttr
=
project_attr
(
systemName
)
def
projectAttr
=
project_attr
(
systemName
)
configPath
=
projectAttr
[
"configPath"
]
configPath
=
projectAttr
[
"configPath"
]
sh
"cp -rf ${contextDir}/config.ini ${configPath}"
sh
"cp -rf ${contextDir}/config.ini ${configPath}"
sh
"tar zcf ${contextDir}/dist.tgz ./*"
sh
"tar zcf ${contextDir}/dist.tgz ./*"
// sh "mv dist.tgz ${contextDir}"
// sh "mv dist.tgz ${contextDir}"
}
}
def
build_luaui
(
systemName
,
branchName
,
contextDir
)
{
def
build_luaui
(
systemName
,
branchName
,
contextDir
)
{
def
projectAttr
=
project_attr
(
systemName
)
def
projectAttr
=
project_attr
(
systemName
)
configPath
=
projectAttr
[
"configPath"
]
configPath
=
projectAttr
[
"configPath"
]
buildCmd
=
projectAttr
[
"buildCmd"
]
buildCmd
=
projectAttr
[
"buildCmd"
]
configName
=
systemName
configName
=
systemName
currentPath
=
sh
(
script:
'pwd'
,
returnStdout:
true
).
trim
()
currentPath
=
sh
(
script:
'pwd'
,
returnStdout:
true
).
trim
()
if
(
systemName
==
'xjd-ui'
&&
branchName
==
'apollo'
){
if
(
systemName
==
'xjd-ui'
&&
branchName
==
'apollo'
){
sh
"npm run build"
sh
"npm run build"
}
else
{
}
else
{
// sh "mv -f ./${systemName}.env.config ${configPath}"
// sh "mv -f ./${systemName}.env.config ${configPath}"
sh
buildCmd
sh
buildCmd
}
}
sh
"tar zcf ${systemName}.tgz dist/"
sh
"tar zcf ${systemName}.tgz dist/"
sh
"mv ${systemName}.tgz ${contextDir}"
sh
"mv ${systemName}.tgz ${contextDir}"
}
}
...
@@ -575,7 +587,7 @@ def dockerbuild_and_push(imageTagInfo,buildNumber,systemName,branchName,cluster,
...
@@ -575,7 +587,7 @@ def dockerbuild_and_push(imageTagInfo,buildNumber,systemName,branchName,cluster,
def
deploy
(
namespace
,
systemName
,
imageTag
,
tier
,
isDeploy
)
{
def
deploy
(
namespace
,
systemName
,
imageTag
,
tier
,
isDeploy
)
{
stage
(
'Deploy To K8s Cluster'
){
stage
(
'Deploy To K8s Cluster'
){
_utils
().
beautyEcho
(
"Deploy To K8S Cluster image: ${imageTag} to:${namespace}"
,
"info"
)
_utils
().
beautyEcho
(
"Deploy To K8S Cluster image: ${imageTag} to:${namespace}"
,
"info"
)
if
(
isDeploy
==
"true"
)
{
if
(
isDeploy
==
"true"
)
{
def
projectAttr
=
project_attr
(
systemName
)
def
projectAttr
=
project_attr
(
systemName
)
...
...
vars/qgDockerPiplineWithDockerSlaveTke.groovy
View file @
00247c2c
...
@@ -3,17 +3,17 @@
...
@@ -3,17 +3,17 @@
*/
*/
def
call
(
body
)
{
def
call
(
body
)
{
ansiColor
(
'xterm'
)
{
ansiColor
(
'xterm'
)
{
// def harborGroup = "library"
// def harborGroup = "library"
def
_stage
=
new
org
.
qg
.
docker_new
.
StageBucketTke
()
def
_stage
=
new
org
.
qg
.
docker_new
.
StageBucketTke
()
def
_utils
=
new
org
.
qg
.
docker_new
.
Utils
()
def
_utils
=
new
org
.
qg
.
docker_new
.
Utils
()
def
config
=
[:]
def
config
=
[:]
def
timeStemp
=
new
Date
().
format
(
"yyyyMMddHHmmssSSS"
)
def
timeStemp
=
new
Date
().
format
(
"yyyyMMddHHmmssSSS"
)
def
env
=
body
.
env
def
env
=
body
.
env
def
gitRepo
=
env
.
GIT_REPO
def
gitRepo
=
env
.
GIT_REPO
def
originBranchName
=
env
.
BRANCH_NAME
def
originBranchName
=
env
.
BRANCH_NAME
def
namespace
=
env
.
NAMESPACE
def
namespace
=
env
.
NAMESPACE
...
@@ -27,26 +27,26 @@ def call(body) {
...
@@ -27,26 +27,26 @@ def call(body) {
t
=
gitRepo
.
split
(
"/"
)
t
=
gitRepo
.
split
(
"/"
)
def
gitGroup
=
t
[
0
]
def
gitGroup
=
t
[
0
]
// systemName or systemName--systemName
// systemName or systemName--systemName
def
originSystemName
=
t
[
1
]
def
originSystemName
=
t
[
1
]
// ["",""]
// ["",""]
def
systemNames
=
originSystemName
.
split
(
"--"
)
def
systemNames
=
originSystemName
.
split
(
"--"
)
def
branchNames
=
originBranchName
.
split
(
"--"
)
def
branchNames
=
originBranchName
.
split
(
"--"
)
def
contextDir
def
contextDir
def
imageTagInfos
def
imageTagInfos
def
branchHashCode
def
branchHashCode
body
.
resolveStrategy
=
Closure
.
DELEGATE_FIRST
body
.
resolveStrategy
=
Closure
.
DELEGATE_FIRST
body
.
delegate
=
config
body
.
delegate
=
config
body
()
body
()
if
(
config
.
harborGroup
!=
null
){
if
(
config
.
harborGroup
!=
null
){
harborGroup
=
config
.
harborGroup
harborGroup
=
config
.
harborGroup
}
}
node
{
node
{
try
{
try
{
echo
config
.
buildType
echo
config
.
buildType
/* 1 */
/* 1 */
stage
(
'Init'
)
{
stage
(
'Init'
)
{
...
@@ -55,7 +55,7 @@ def call(body) {
...
@@ -55,7 +55,7 @@ def call(body) {
_stage
.
init_dependency
()
_stage
.
init_dependency
()
_stage
.
init_image_dependency
(
config
.
buildType
,
originSystemName
,
contextDir
)
_stage
.
init_image_dependency
(
config
.
buildType
,
originSystemName
,
contextDir
)
}
}
/* 2 */
/* 2 */
echo
originSystemName
echo
originSystemName
withDockerServer
([
uri:
"tcp://192.168.4.96:2375/"
])
{
withDockerServer
([
uri:
"tcp://192.168.4.96:2375/"
])
{
...
@@ -65,17 +65,17 @@ def call(body) {
...
@@ -65,17 +65,17 @@ def call(body) {
branchHashCode
=
_stage
.
check_and_build
(
config
.
buildType
,
systemNames
[
i
],
branchNames
[
i
],
contextDir
)
branchHashCode
=
_stage
.
check_and_build
(
config
.
buildType
,
systemNames
[
i
],
branchNames
[
i
],
contextDir
)
}
}
}
}
_utils
.
beautyEcho
(
"build over"
,
"info"
)
_utils
.
beautyEcho
(
"build over"
,
"info"
)
}
}
/* 3 */
/* 3 */
withDockerServer
([
uri:
"tcp://192.168.4.96:2375/"
])
{
withDockerServer
([
uri:
"tcp://192.168.4.96:2375/"
])
{
_utils
.
beautyEcho
(
"make docker image"
,
"stage"
)
_utils
.
beautyEcho
(
"make docker image"
,
"stage"
)
/*def _systemName = originSystemName.toLowerCase()*/
/*def _systemName = originSystemName.toLowerCase()*/
def
regex
=
"[`,./;\\[\\]&<>?:\"()|-]+"
def
regex
=
"[`,./;\\[\\]&<>?:\"()|-]+"
def
k8sSystemName
=
originSystemName
.
replaceAll
(
"_"
,
"-"
).
toLowerCase
()
def
k8sSystemName
=
originSystemName
.
replaceAll
(
"_"
,
"-"
).
toLowerCase
()
def
safeBranchName
=
originBranchName
.
replaceAll
(
regex
,
"_"
).
toLowerCase
()
def
safeBranchName
=
originBranchName
.
replaceAll
(
regex
,
"_"
).
toLowerCase
()
imageTagInfos
=
_stage
.
imageTag
(
harborGroup
,
k8sSystemName
,
safeBranchName
,
timeStemp
)
imageTagInfos
=
_stage
.
imageTag
(
harborGroup
,
k8sSystemName
,
safeBranchName
,
timeStemp
)
for
(
imageTagInfo
in
imageTagInfos
){
for
(
imageTagInfo
in
imageTagInfos
){
...
@@ -83,20 +83,22 @@ def call(body) {
...
@@ -83,20 +83,22 @@ def call(body) {
}
}
_stage
.
deploy
(
namespace
,
originSystemName
,
imageTagInfos
[
0
][
"imageTag"
],
config
.
tier
,
isDeploy
)
_stage
.
deploy
(
namespace
,
originSystemName
,
imageTagInfos
[
0
][
"imageTag"
],
config
.
tier
,
isDeploy
)
}
}
/* 4 */
/* 4 */
stage
(
'Clean'
){
stage
(
'Clean'
){
_utils
.
beautyEcho
(
"Clear Cache Tmp"
,
"stage"
)
_utils
.
beautyEcho
(
"Clear Cache Tmp"
,
"stage"
)
_stage
.
clean_images
(
imageTagInfos
[
0
][
"imageTag"
],
imageTagInfos
[
0
][
"imageTagCode"
],
contextDir
,
config
.
buildType
)
_stage
.
clean_images
(
imageTagInfos
[
0
][
"imageTag"
],
imageTagInfos
[
0
][
"imageTagCode"
],
contextDir
,
config
.
buildType
)
_stage
.
ding_talk
(
buildNumber
,
"success"
)
}
}
}
catch
(
err
)
{
}
catch
(
err
)
{
_utils
.
beautyEcho
(
err
,
"fail"
)
_utils
.
beautyEcho
(
err
,
"fail"
)
_stage
.
ding_talk
(
buildNumber
,
"fail"
)
if
(
imageTagInfos
!=
null
){
if
(
imageTagInfos
!=
null
){
_stage
.
clean_images
(
imageTagInfos
[
0
][
"imageTag"
],
imageTagInfos
[
0
][
"imageTagCode"
],
contextDir
,
config
.
buildType
)
_stage
.
clean_images
(
imageTagInfos
[
0
][
"imageTag"
],
imageTagInfos
[
0
][
"imageTagCode"
],
contextDir
,
config
.
buildType
)
}
}
throw
err
throw
err
}
}
}
}
}
}
}
}
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