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
188113f8
Commit
188113f8
authored
Apr 09, 2018
by
wentao.suo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fffff
parent
689e5392
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
47 deletions
+48
-47
StageBucket.groovy
src/org/qg/docker_new/StageBucket.groovy
+33
-23
qgDockerPiplineWithDockerSlave.groovy
vars/qgDockerPiplineWithDockerSlave.groovy
+15
-24
No files found.
src/org/qg/docker_new/StageBucket.groovy
View file @
188113f8
...
@@ -260,21 +260,7 @@ def dockerbuild_and_push(timeNow, buildNumber, branchName, harborGroup, systemNa
...
@@ -260,21 +260,7 @@ def dockerbuild_and_push(timeNow, buildNumber, branchName, harborGroup, systemNa
return
imageTag
return
imageTag
}
}
def
deploy
(
namespace
,
systemName
,
imageTag
,
tier
,
isDeploy
)
{
def
deploy_job_info
if
(
isDeploy
==
"true"
)
{
_utils
().
beautyEcho
(
"[新集群][deployV2]将镜像更新到到Namespace:"
+
namespace
,
"info"
)
update_microservice
(
namespace
,
systemName
,
imageTag
,
tier
)
}
else
{
_utils
().
beautyEcho
(
"isDeploy == false,不执行deploy"
,
"info"
)
}
}
def
clean_images
(
imageTag
)
{
sh
"docker rmi -f \$(docker images -q ${imageTag})"
}
@NonCPS
@NonCPS
def
jsonParse
(
def
json
)
{
def
jsonParse
(
def
json
)
{
...
@@ -360,16 +346,18 @@ def checkAndBuild(buildType,systemName,branchName,contextDir){
...
@@ -360,16 +346,18 @@ def checkAndBuild(buildType,systemName,branchName,contextDir){
docker
.
image
(
pacegeDockerInfo
[
"image"
]).
inside
(
pacegeDockerInfo
[
"args"
]){
docker
.
image
(
pacegeDockerInfo
[
"image"
]).
inside
(
pacegeDockerInfo
[
"args"
]){
/*checkout code*/
/*checkout code*/
stage
(
'checkout'
)
{
checkout
(
buildType
,
systemName
,
branchName
)
checkout
(
buildType
,
systemName
,
branchName
)
}
/*prepare config*/
/*prepare config*/
stage
(
'prepare config'
)
{
prepare_config
(
buildType
,
systemName
,
contextDir
)
prepare_config
(
buildType
,
systemName
,
contextDir
)
}
/*build*/
/*build*/
stage
(
'build'
){
build
(
buildType
,
systemName
,
contextDir
)
}
build
(
buildType
,
systemName
,
contextDir
)
...
@@ -378,8 +366,8 @@ def checkAndBuild(buildType,systemName,branchName,contextDir){
...
@@ -378,8 +366,8 @@ def checkAndBuild(buildType,systemName,branchName,contextDir){
def
dockerMake
(
imageTag
,
buildNumber
,
systemName
,
branchName
,
cluster
,
timeStemp
){
def
dockerMake
(
imageTag
,
buildNumber
,
systemName
,
branchName
,
cluster
,
timeStemp
){
stage
(
'make docker image'
)
{
withDockerRegistry
([
credentialsId:
'harbor-qajenkins'
,
url:
"http://192.168.4.36"
])
{
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
build_schema
=
"BUILD_TIME:${timeStemp}@BUILD_NUMBER:${buildNumber}@SYSTEM_NAME:${systemName}@BRANCH_NAME:${branchName}@CLUSTER:${cluster}"
echo
build_schema
echo
build_schema
...
@@ -398,7 +386,29 @@ def dockerMake(imageTag,buildNumber,systemName,branchName,cluster,timeStemp){
...
@@ -398,7 +386,29 @@ def dockerMake(imageTag,buildNumber,systemName,branchName,cluster,timeStemp){
}
}
}
}
}
}
def
deploy
(
namespace
,
systemName
,
imageTag
,
tier
,
isDeploy
)
{
stage
(
'Deploy To K8s Cluster'
){
def
deploy_job_info
if
(
isDeploy
==
"true"
)
{
_utils
().
beautyEcho
(
"[新集群][deployV2]将镜像更新到到Namespace:"
+
namespace
,
"info"
)
update_microservice
(
namespace
,
systemName
,
imageTag
,
tier
)
}
else
{
_utils
().
beautyEcho
(
"isDeploy == false,不执行deploy"
,
"info"
)
}
}
}
def
clean_images
(
imageTag
,
contextDir
)
{
sh
"rm -rf ${contextDir}"
if
(
imageTag
){
clean_images
(
imageTag
)
}
}
}
vars/qgDockerPiplineWithDockerSlave.groovy
View file @
188113f8
...
@@ -50,33 +50,29 @@ def call(body) {
...
@@ -50,33 +50,29 @@ def call(body) {
/* 2 */
/* 2 */
withDockerServer
([
uri:
"tcp://192.168.4.96:2375/"
])
{
withDockerServer
([
uri:
"tcp://192.168.4.96:2375/"
])
{
_utils
.
beautyEcho
(
"checkout & build"
,
"stage"
)
stage
(
'checkout & build'
)
{
_utils
.
beautyEcho
(
"checkout & build"
,
"stage"
)
arrSystem
=
systemName
.
split
(
"--"
)
for
(
systemNameSimple
in
arrSystem
)
{
dir
(
systemNameSimple
){
_stage
.
checkAndBuild
(
config
.
buildType
,
systemNameSimple
,
branchName
,
contextDir
)
}
}
_utils
.
beautyEcho
(
"build over"
,
"info"
)
arrSystem
=
systemName
.
split
(
"--"
)
for
(
systemNameSimple
in
arrSystem
)
{
dir
(
systemNameSimple
){
_stage
.
checkAndBuild
(
config
.
buildType
,
systemNameSimple
,
branchName
,
contextDir
)
}
}
}
_utils
.
beautyEcho
(
"build over"
,
"info"
)
}
}
/* 3 */
/* 3 */
withDockerServer
([
uri:
"tcp://192.168.4.96:2375/"
])
{
withDockerServer
([
uri:
"tcp://192.168.4.96:2375/"
])
{
stage
(
'make docker image'
)
{
_utils
.
beautyEcho
(
"make docker image"
,
"stage"
)
_utils
.
beautyEcho
(
"make docker image"
,
"stage"
)
imageTag
=
_stage
.
imageTag
(
harborGroup
,
k8sSystemName
,
safeBranchName
,
timeStemp
)
imageTag
=
_stage
.
imageTag
(
harborGroup
,
k8sSystemName
,
safeBranchName
,
timeStemp
)
_stage
.
dockerMake
(
imageTag
,
buildNumber
,
systemName
,
branchName
,
cluster
,
timeStemp
)
_stage
.
dockerMake
(
imageTag
,
buildNumber
,
systemName
,
branchName
,
cluster
,
timeStemp
)
}
stage
(
'Deploy To K8s Cluster'
){
_utils
.
beautyEcho
(
"Deploy To K8s Cluster"
,
"stage"
)
_utils
.
beautyEcho
(
"Deploy To K8s Cluster"
,
"stage"
)
_utils
.
beautyEcho
(
"Deploy image: ${imageTag} to:${namespace}"
,
"info"
)
_utils
.
beautyEcho
(
"Deploy image: ${imageTag} to:${namespace}"
,
"info"
)
_stage
.
deploy
(
namespace
,
systemName
,
imageTag
,
config
.
tier
,
isDeploy
)
_stage
.
deploy
(
namespace
,
systemName
,
imageTag
,
config
.
tier
,
isDeploy
)
...
@@ -87,19 +83,14 @@ def call(body) {
...
@@ -87,19 +83,14 @@ def call(body) {
/* 4 */
/* 4 */
stage
(
'Clear Cache Tmp'
){
stage
(
'Clear Cache Tmp'
){
_utils
.
beautyEcho
(
"Clear Cache Tmp"
,
"stage"
)
_utils
.
beautyEcho
(
"Clear Cache Tmp"
,
"stage"
)
sh
"rm -rf ${contextDir}"
_stage
.
clean_images
(
imageTag
,
contextDir
)
_stage
.
clean_images
(
imageTag
)
}
}
}
catch
(
err
)
{
}
catch
(
err
)
{
_utils
.
beautyEcho
(
err
,
"fail"
)
_utils
.
beautyEcho
(
err
,
"fail"
)
sh
"rm -rf ${contextDir}"
_stage
.
clean_images
(
imageTag
,
contextDir
)
if
(
imageTag
){
_stage
.
clean_images
(
imageTag
)
}
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