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
02eea142
Commit
02eea142
authored
Apr 10, 2018
by
wentao.suo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fffff
parent
52a9c799
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
18 deletions
+20
-18
StageBucket.groovy
src/org/qg/docker_new/StageBucket.groovy
+15
-13
qgDockerPiplineWithDockerSlave.groovy
vars/qgDockerPiplineWithDockerSlave.groovy
+5
-5
No files found.
src/org/qg/docker_new/StageBucket.groovy
View file @
02eea142
...
...
@@ -311,22 +311,22 @@ def getDocketPackageImage(buildType){
return
packageImageInfo
}
def
check
AndB
uild
(
buildType
,
systemName
,
branchName
,
contextDir
){
def
check
_and_b
uild
(
buildType
,
systemName
,
branchName
,
contextDir
){
def
pacegeDockerInfo
=
getDocketPackageImage
(
buildType
)
docker
.
image
(
pacegeDockerInfo
[
"image"
]).
inside
(
pacegeDockerInfo
[
"args"
]){
/*checkout code*/
stage
(
'
c
heckout'
)
{
stage
(
'
C
heckout'
)
{
checkout
(
buildType
,
systemName
,
branchName
)
}
/*prepare config*/
stage
(
'
config
'
)
{
stage
(
'
Prepare
'
)
{
prepare_config
(
buildType
,
systemName
,
contextDir
)
}
/*build*/
stage
(
'
b
uild'
){
stage
(
'
B
uild'
){
build
(
buildType
,
systemName
,
contextDir
)
}
...
...
@@ -336,9 +336,9 @@ def checkAndBuild(buildType,systemName,branchName,contextDir){
}
}
def
docker
Make
(
imageTag
,
buildNumber
,
systemName
,
branchName
,
cluster
,
timeStemp
){
def
docker
build_and_push
(
imageTag
,
buildNumber
,
systemName
,
branchName
,
cluster
,
timeStemp
){
stage
(
'
image
'
)
{
stage
(
'
Docker Build And Push
'
)
{
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}"
...
...
@@ -356,6 +356,8 @@ def dockerMake(imageTag,buildNumber,systemName,branchName,cluster,timeStemp){
if
(
branchName
==
"master"
||
branchName
==
"master--master"
)
{
image
.
push
(
'latest'
)
}
_utils
().
beautyEcho
(
"镜像地址:${imageTag}"
,
"info"
)
}
}
...
...
@@ -364,7 +366,7 @@ def dockerMake(imageTag,buildNumber,systemName,branchName,cluster,timeStemp){
def
deploy
(
namespace
,
systemName
,
imageTag
,
tier
,
isDeploy
)
{
stage
(
'
deploy
'
){
stage
(
'
Deploy To K8s Cluster
'
){
def
deploy_job_info
if
(
isDeploy
==
"true"
)
{
...
...
@@ -377,12 +379,12 @@ def deploy(namespace, systemName, imageTag, tier, isDeploy) {
}
}
def
dockerbuild_and_push
(
timeNow
,
buildNumber
,
branchName
,
harborGroup
,
systemName
,
contextDir
)
{
/*
def dockerbuild_and_push(timeNow, buildNumber, branchName, harborGroup, systemName, contextDir) {
regex = "[`,./;\\[\\]&<>?:\"()|-]+"
k8sSystemName = systemName.replaceAll("_","-")
safeBranchName = branchName.replaceAll(regex,"_")
defaultSystemName
=
"project"
defaultSystemName = "project"
timeStemp = new Date().format("yyyyMMddHHmmss")
imageTag = "192.168.4.36/${harborGroup}/${k8sSystemName}:${safeBranchName}-${timeStemp}"
...
...
@@ -391,17 +393,17 @@ def dockerbuild_and_push(timeNow, buildNumber, branchName, harborGroup, systemNa
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
}
}
*/
def
clean_images
(
imageTag
,
contextDir
)
{
sh
"rm -rf ${contextDir}"
...
...
vars/qgDockerPiplineWithDockerSlave.groovy
View file @
02eea142
...
...
@@ -41,8 +41,8 @@ def call(body) {
try
{
echo
config
.
buildType
/* 1 */
stage
(
'
prepare
'
)
{
_utils
.
beautyEcho
(
"
Prepare
"
,
"stage"
)
stage
(
'
Init
'
)
{
_utils
.
beautyEcho
(
"
Init
"
,
"stage"
)
contextDir
=
_stage
.
contextMkdir
(
"${systemName}-${timeStemp}"
)
_stage
.
before_prepare
()
}
...
...
@@ -56,7 +56,7 @@ def call(body) {
arrSystem
=
systemName
.
split
(
"--"
)
for
(
systemNameSimple
in
arrSystem
)
{
dir
(
systemNameSimple
){
_stage
.
check
AndB
uild
(
config
.
buildType
,
systemNameSimple
,
branchName
,
contextDir
)
_stage
.
check
_and_b
uild
(
config
.
buildType
,
systemNameSimple
,
branchName
,
contextDir
)
}
}
_utils
.
beautyEcho
(
"build over"
,
"info"
)
...
...
@@ -68,7 +68,7 @@ def call(body) {
withDockerServer
([
uri:
"tcp://192.168.4.96:2375/"
])
{
_utils
.
beautyEcho
(
"make docker image"
,
"stage"
)
imageTag
=
_stage
.
imageTag
(
harborGroup
,
k8sSystemName
,
safeBranchName
,
timeStemp
)
_stage
.
docker
Make
(
imageTag
,
buildNumber
,
systemName
,
branchName
,
cluster
,
timeStemp
)
_stage
.
docker
build_and_push
(
imageTag
,
buildNumber
,
systemName
,
branchName
,
cluster
,
timeStemp
)
_utils
.
beautyEcho
(
"Deploy To K8s Cluster image: ${imageTag} to:${namespace}"
,
"stage"
)
_stage
.
deploy
(
namespace
,
systemName
,
imageTag
,
config
.
tier
,
isDeploy
)
...
...
@@ -78,7 +78,7 @@ def call(body) {
}
/* 4 */
stage
(
'
clear
'
){
stage
(
'
Clean
'
){
_utils
.
beautyEcho
(
"Clear Cache Tmp"
,
"stage"
)
_stage
.
clean_images
(
imageTag
,
contextDir
)
}
...
...
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