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
06ffc612
Commit
06ffc612
authored
Apr 03, 2018
by
wentao.suo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fff
parent
42f45de1
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
497 additions
and
0 deletions
+497
-0
StageBucket.groovy
src/org/qg/docker_new/StageBucket.groovy
+313
-0
Utils.groovy
src/org/qg/docker_new/Utils.groovy
+55
-0
qgDockerPiplineWithDocer.groovy
vars/qgDockerPiplineWithDocer.groovy
+129
-0
No files found.
src/org/qg/docker_new/StageBucket.groovy
0 → 100644
View file @
06ffc612
This diff is collapsed.
Click to expand it.
src/org/qg/docker_new/Utils.groovy
0 → 100644
View file @
06ffc612
// src/org/qg/docker/Utils.groovy
package
org.qg.docker
;
def
root
=
"/home/quantgroup/"
def
contextDir
(
key
)
{
uuid
=
UUID
.
randomUUID
().
toString
()
contextDir
=
"/home/quant_group/pacakge//${key}"
return
contextDir
}
def
beautyEcho
(
content
,
type
)
{
red
=
"31"
green
=
"32"
blue
=
"34"
purple
=
"35"
darkgreen
=
"36"
result
=
""
switch
(
type
)
{
case
"info"
:
content
=
" ➢➢➢➢➢ ${content}"
result
=
"\033[${blue}m${content}\033[0m"
break
case
"success"
:
content
=
" ✔✔✔✔✔ ${content}"
result
=
"\033[${green}m${content}\033[0m"
break
case
"fail"
:
content
=
" ✘✘✘✘✘ ${content}"
result
=
"\033[${red}m${content}\033[0m"
break
case
"stage"
:
content
=
" ✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩ ${content} ✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩✩"
result
=
"\033[${purple}m${content}\033[0m"
break
default:
result
=
content
break
}
echo
result
}
def
copyDockerFiles
()
{
}
def
copyConfigFiles
()
{
}
return
this
;
\ No newline at end of file
vars/qgDockerPiplineWithDocer.groovy
0 → 100644
View file @
06ffc612
import
org.qg.docker.*
import
java.time.*
def
getTime
(){
LocalDateTime
t
=
LocalDateTime
.
now
();
return
t
as
String
}
def
call
(
body
)
{
def
config
=
[:]
def
env
=
body
.
env
def
branchName
=
env
.
BRANCH_NAME
def
gitRepo
=
env
.
GIT_REPO
def
namespace
=
env
.
NAMESPACE
def
isDeploy
=
env
.
IS_DEPLOY
def
buildNumber
=
env
.
BUILD_NUMBER
def
cluster
=
env
.
CLUSTER
t
=
gitRepo
.
split
(
"/"
)
def
gitGroup
=
t
[
0
]
def
originSystemName
=
t
[
1
]
def
systemName
=
originSystemName
.
toLowerCase
()
echo
"====JOB_NAME : ${env.JOB_NAME}"
def
harborGroup
=
"library"
/* def workspace = "/home/quant_ group/jenkins_home/workspace/${env.JOB_NAME}"*/
def
imageTag
def
timeStemp
=
new
Date
().
format
(
"yyyyMMddHHmmss"
)
def
_stage
=
new
org
.
qg
.
docker
.
StageBucket
()
def
_utils
=
new
org
.
qg
.
docker
.
Utils
()
def
contextDir
=
"/home/quant_group/pacakge/${systemName}-${timeStemp}"
body
.
resolveStrategy
=
Closure
.
DELEGATE_FIRST
body
.
delegate
=
config
body
()
node
{
try
{
sh
"mkdir -p ${contextDir}"
withDockerServer
([
uri:
"tcp://192.168.4.96:2375/"
])
{
def
volume
=
"-v /root/.m2:/root/.m2 "
volume
+=
"-v /home/quant_group/qg-dockerfiles:/home/quant_group/qg-dockerfiles "
volume
+=
"-v /home/quant_group/config_repository:/home/quant_group/config_repository "
volume
+=
"-v /home/quant_group/pacakge/:/home/quant_group/pacakge/ "
docker
.
image
(
"192.168.4.36/baseimg/jenkins-slave:2018040302"
).
inside
(
volume
){
git_path
=
project_attr
(
systemName
)[
"gitPath"
]
if
(
git_path
==
"git@gitabc.xyqb.com:data-riskcontrol/urge-dispatcher.git"
){
git_path
=
"git@gitabc.xyqb.com:data-riskcontrol/urge_dispatcher.git"
}
git
branch:
branchName
,
credentialsId:
'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db'
,
url:
git_path
sh
'mvn clean package -P test -D maven.test.skip=true'
applicaton_properties
=
"/home/quant_group/config_repository/java/${systemName}.properties"
echo
applicaton_properties
sh
"if [ -f ${applicaton_properties} ]; then cp -rf ${applicaton_properties} ${contextDir}/application.properties; else echo \"## useing apollo ##\" > ${contextDir}/application.properties; fi"
sh
"cp -rf /home/quant_group/qg-dockerfiles/templates_new/java/* ${contextDir}"
sh
"cp target/*.jar ${contextDir}/app.jar"
}
regex
=
"[`,./;\\[\\]&<>?:\"()|-]+"
k8sSystemName
=
systemName
.
replaceAll
(
"_"
,
"-"
)
safeBranchName
=
branchName
.
replaceAll
(
regex
,
"_"
)
defaultSystemName
=
"project"
timeStemp
=
new
Date
().
format
(
"yyyyMMddHHmmss"
)
imageTag
=
"192.168.4.36/${harborGroup}/${k8sSystemName}:${safeBranchName}-${timeStemp}"
withDockerRegistry
([
credentialsId:
'harbor-qajenkins'
,
url:
"http://192.168.4.36"
])
{
def
build_schema
=
"BUILD_TIME: ${timeStemp} ,BUILD_NUMBER: ${buildNumber},SYSTEM_NAME: ${systemName},BRANCH_NAME: ${branchName}, CLUSTER: ${cluster}"
def
image
=
docker
.
build
(
imageTag
,
"--build-arg BUILD_SHCEMA=build_schema ${contextDir}"
)
image
.
push
()
if
(
branchName
==
"master"
||
branchName
==
"master--master"
)
{
image
.
push
(
'latest'
)
}
}
}
}
catch
(
err
)
{
ansiColor
(
'xterm'
)
{
currentBuild
.
result
=
'FAILED'
/*_utils.beautyEcho(err, "fail")*/
throw
err
}
}
finlly
(){
sh
"rm -rf ${contextDir}"
_stage
.
clean_images
(
imageTag
)
}
}
}
@NonCPS
def
jsonParse
(
def
json
)
{
new
groovy
.
json
.
JsonSlurperClassic
().
parseText
(
json
)
}
def
project_attr
(
systemName
)
{
response
=
httpRequest
"http://192.168.4.3:10088/config_server/get_project_attr/${systemName}"
def
res_json
=
jsonParse
(
response
.
content
)
return
res_json
}
\ No newline at end of file
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