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
b85749a9
Commit
b85749a9
authored
Mar 01, 2018
by
wentao.suo
Browse files
Options
Browse Files
Download
Plain Diff
change dockerbuild_and_push buildNumber to date String
parents
b0253190
bd9bc3fb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
7 deletions
+42
-7
StageBucket.groovy
src/org/qg/docker/StageBucket.groovy
+33
-5
StageBucket.groovy
src/org/qg/tools/StageBucket.groovy
+1
-0
qgDockerPipeline.groovy
vars/qgDockerPipeline.groovy
+8
-2
No files found.
src/org/qg/docker/StageBucket.groovy
View file @
b85749a9
...
@@ -230,9 +230,9 @@ def dockerbuild_and_push(timeNow, buildNumber, branchName, harborGroup, systemNa
...
@@ -230,9 +230,9 @@ def dockerbuild_and_push(timeNow, buildNumber, branchName, harborGroup, systemNa
defaultSystemName
=
"project"
defaultSystemName
=
"project"
timeStemp
=
new
Date
().
format
(
"yyyyMMddHHmmss"
)
timeStemp
=
new
Date
().
format
(
"yyyyMMddHHmmss"
)
imageTag
=
"192.168.4.36/${harborGroup}/${k8sSystemName}:${safeBranchName}-${
timeStemp
}"
imageTag
=
"192.168.4.36/${harborGroup}/${k8sSystemName}:${safeBranchName}-${
buildNumber
}"
withDockerServer
([
uri:
"tcp://192.168.4.96:2375/"
])
{
withDockerServer
([
uri:
"tcp://192.168.4.96:2375/"
])
{
withDockerRegistry
([
credentialsId:
'harbor-qajenkins'
,
url:
"http://192.168.4.36"
])
{
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}"
)
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}"
)
...
@@ -253,7 +253,7 @@ def deploy(namespace, systemName, imageTag, tier, isDeploy) {
...
@@ -253,7 +253,7 @@ def deploy(namespace, systemName, imageTag, tier, isDeploy) {
def
deploy_job_info
def
deploy_job_info
if
(
isDeploy
==
"true"
)
{
if
(
isDeploy
==
"true"
)
{
_utils
().
beautyEcho
(
"将镜像更新到到Namespace:"
+
namespace
,
"info"
)
_utils
().
beautyEcho
(
"
[旧集群][deploy]
将镜像更新到到Namespace:"
+
namespace
,
"info"
)
deploy_job_info
=
build
job:
'3.deployer.Updater'
,
parameters:
[
deploy_job_info
=
build
job:
'3.deployer.Updater'
,
parameters:
[
string
(
name:
'namespace'
,
value:
"${namespace}"
),
string
(
name:
'namespace'
,
value:
"${namespace}"
),
string
(
name:
'name'
,
value:
"${systemName}"
),
string
(
name:
'name'
,
value:
"${systemName}"
),
...
@@ -267,6 +267,18 @@ def deploy(namespace, systemName, imageTag, tier, isDeploy) {
...
@@ -267,6 +267,18 @@ def deploy(namespace, systemName, imageTag, tier, isDeploy) {
}
}
}
}
def
deployV2
(
namespace
,
systemName
,
imageTag
,
tier
,
isDeploy
)
{
def
deploy_job_info
if
(
isDeploy
==
"true"
)
{
_utils
().
beautyEcho
(
"[新集群][deployV2]将镜像更新到到Namespace:"
+
namespace
,
"info"
)
log
=
update_microservice
(
namespace
,
systemName
,
imageTag
,
tier
)
return
log
}
else
{
_utils
().
beautyEcho
(
"namespace:[${namespace}]不存在,不执行deploy"
,
"info"
)
}
}
def
clean_images
(
imageTag
)
{
def
clean_images
(
imageTag
)
{
sh
"docker rmi -f \$(docker images -q ${imageTag})"
sh
"docker rmi -f \$(docker images -q ${imageTag})"
}
}
...
@@ -280,4 +292,20 @@ def project_attr(systemName) {
...
@@ -280,4 +292,20 @@ def project_attr(systemName) {
response
=
httpRequest
"http://192.168.4.3:10088/config_server/get_project_attr/${systemName}"
response
=
httpRequest
"http://192.168.4.3:10088/config_server/get_project_attr/${systemName}"
def
res_json
=
jsonParse
(
response
.
content
)
def
res_json
=
jsonParse
(
response
.
content
)
return
res_json
return
res_json
}
}
\ No newline at end of file
def
update_microservice
(
namespace
,
name
,
image
,
tier
)
{
dest_url
=
"http://192.168.4.24/api/qahome/update_microservice"
json_str
=
'{"namespace":'
+
namespace
+
',"name":'
+
name
+
',"image":'
+
image
+
',"tier":'
+
tier
+
'}'
echo
json_str
j
=
readJSON
text:
json_str
response
=
httpRequest
contentType:
"APPLICATION_JSON"
,
httpMode:
"PUT"
,
requestBody:
JsonOutput
.
toJson
(
j
),
url:
dest_url
def
res_json
=
jsonParse
(
response
.
content
)
return
res_json
}
src/org/qg/tools/StageBucket.groovy
View file @
b85749a9
...
@@ -24,6 +24,7 @@ def checkout_eos(branchName) {
...
@@ -24,6 +24,7 @@ def checkout_eos(branchName) {
def
build_eos
(
contextDir
)
{
def
build_eos
(
contextDir
)
{
sh
"mv run.py ${contextDir}"
sh
"mv run.py ${contextDir}"
sh
"mv requirements.txt ${contextDir}"
sh
'tar zcf dist.tgz app/'
sh
'tar zcf dist.tgz app/'
sh
"mv dist.tgz ${contextDir}"
sh
"mv dist.tgz ${contextDir}"
}
}
...
...
vars/qgDockerPipeline.groovy
View file @
b85749a9
...
@@ -115,8 +115,14 @@ def call(body) {
...
@@ -115,8 +115,14 @@ def call(body) {
stage
(
'Deploy To K8s Cluster'
)
{
stage
(
'Deploy To K8s Cluster'
)
{
_utils
.
beautyEcho
(
"Deploy To K8s Cluster"
,
"stage"
)
_utils
.
beautyEcho
(
"Deploy To K8s Cluster"
,
"stage"
)
def
deploy_log
=
_stage
.
deploy
(
namespace
,
systemName
,
imageTag
,
config
.
tier
,
isDeploy
)
_utils
.
beautyEcho
(
deploy_log
,
"info"
)
def
deploy_log
if
(
config
.
cluster
==
"271"
)
{
deploy_log
=
_stage
.
deployV2
(
namespace
,
systemName
,
imageTag
,
config
.
tier
,
isDeploy
)
}
else
{
deploy_log
=
_stage
.
deploy
(
namespace
,
systemName
,
imageTag
,
config
.
tier
,
isDeploy
)
}
_utils
.
beautyEcho
(
deploy_log
,
"info"
)
}
}
stage
(
"Clean"
)
{
stage
(
"Clean"
)
{
...
...
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