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
02b89017
Commit
02b89017
authored
Apr 03, 2018
by
wentao.suo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fff
parent
2fc01b1c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
75 deletions
+76
-75
qgDockerPiplineWithDocer.groovy
vars/qgDockerPiplineWithDocer.groovy
+76
-75
No files found.
vars/qgDockerPiplineWithDocer.groovy
View file @
02b89017
...
...
@@ -3,113 +3,114 @@
def
call
(
body
)
{
def
_stage
=
new
org
.
qg
.
docker_new
.
StageBucket
()
def
_utils
=
new
org
.
qg
.
docker_new
.
Utils
()
ansiColor
(
'xterm'
)
{
def
_stage
=
new
org
.
qg
.
docker_new
.
StageBucket
()
def
_utils
=
new
org
.
qg
.
docker_new
.
Utils
()
def
config
=
[:]
def
timeStemp
=
new
Date
().
format
(
"yyyyMMddHHmmss"
)
def
config
=
[:]
def
timeStemp
=
new
Date
().
format
(
"yyyyMMddHHmmss"
)
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
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
systemName
=
t
[
1
].
toLowerCase
()
t
=
gitRepo
.
split
(
"/"
)
def
gitGroup
=
t
[
0
]
def
systemName
=
t
[
1
].
toLowerCase
()
def
contextDir
def
imageTag
def
contextDir
def
imageTag
regex
=
"[`,./;\\[\\]&<>?:\"()|-]+"
regex
=
"[`,./;\\[\\]&<>?:\"()|-]+"
k8sSystemName
=
systemName
.
replaceAll
(
"_"
,
"-"
)
safeBranchName
=
branchName
.
replaceAll
(
regex
,
"_"
)
k8sSystemName
=
systemName
.
replaceAll
(
"_"
,
"-"
)
safeBranchName
=
branchName
.
replaceAll
(
regex
,
"_"
)
body
.
resolveStrategy
=
Closure
.
DELEGATE_FIRST
body
.
delegate
=
config
body
()
body
.
resolveStrategy
=
Closure
.
DELEGATE_FIRST
body
.
delegate
=
config
body
()
node
{
node
{
try
{
echo
config
.
buildType
stage
(
'prepare'
)
{
_utils
.
beautyEcho
(
"Prepare"
,
"stage"
)
contextDir
=
_stage
.
contextMkdir
(
"${systemName}-${timeStemp}"
)
_stage
.
before_prepare
()
}
try
{
echo
config
.
buildType
stage
(
'prepare'
)
{
_utils
.
beautyEcho
(
"Prepare"
,
"stage"
)
contextDir
=
_stage
.
contextMkdir
(
"${systemName}-${timeStemp}"
)
_stage
.
before_prepare
()
}
pacegeDockerInfo
=
_stage
.
getDocketPackageImage
(
config
.
buildType
)
pacegeDockerInfo
=
_stage
.
getDocketPackageImage
(
config
.
buildType
)
withDockerServer
([
uri:
"tcp://192.168.4.96:2375/"
])
{
withDockerServer
([
uri:
"tcp://192.168.4.96:2375/"
])
{
stage
(
'checkout & build'
)
{
_utils
.
beautyEcho
(
"checkout & build"
,
"stage"
)
stage
(
'checkout & build'
)
{
_utils
.
beautyEcho
(
"checkout & build"
,
"stage"
)
docker
.
image
(
pacegeDockerInfo
[
"images"
]).
inside
(
pacegeDockerInfo
[
"args"
]){
docker
.
image
(
pacegeDockerInfo
[
"images"
]).
inside
(
pacegeDockerInfo
[
"args"
]){
project_attr
=
_stage
.
project_attr
(
systemName
)
gitPath
=
project_attr
[
"gitPath"
]
project_attr
=
_stage
.
project_attr
(
systemName
)
gitPath
=
project_attr
[
"gitPath"
]
/*checkout code*/
_utils
.
beautyEcho
(
"checkout"
,
"stage"
)
_stage
.
checkout
(
git_path
,
branchName
)
/*checkout code*/
_utils
.
beautyEcho
(
"checkout"
,
"stage"
)
_stage
.
checkout
(
git_path
,
branchName
)
/*prepare config*/
_utils
.
beautyEcho
(
"prepare config"
,
"stage"
)
_stage
.
prepare_config
(
systemName
,
contextDir
)
/*prepare config*/
_utils
.
beautyEcho
(
"prepare config"
,
"stage"
)
_stage
.
prepare_config
(
systemName
,
contextDir
)
/*build*/
_utils
.
beautyEcho
(
"build"
,
"stage"
)
buildCmd
=
project_attr
[
"buildCmd"
]
sh
"${buildCmd}"
/*build*/
_utils
.
beautyEcho
(
"build"
,
"stage"
)
buildCmd
=
project_attr
[
"buildCmd"
]
sh
"${buildCmd}"
/*copy files*/
_stage
.
copy_files
(
config
.
buildType
,
project_attr
[
"jarFilePath"
],
contextDir
)
/*copy files*/
_stage
.
copy_files
(
config
.
buildType
,
project_attr
[
"jarFilePath"
],
contextDir
)
}
}
}
stage
(
'make docker image'
)
{
stage
(
'make docker image'
)
{
imageTag
=
"192.168.4.36/${harborGroup}/${k8sSystemName}:${safeBranchName}-${timeStemp}"
withDockerRegistry
([
credentialsId:
'harbor-qajenkins'
,
url:
"http://192.168.4.36"
])
{
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
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
()
def
image
=
docker
.
build
(
imageTag
,
"--build-arg BUILD_SHCEMA=build_schema ${contextDir}"
)
image
.
push
()
if
(
branchName
==
"master"
||
branchName
==
"master--master"
)
{
image
.
push
(
'latest'
)
}
if
(
branchName
==
"master"
||
branchName
==
"master--master"
)
{
image
.
push
(
'latest'
)
}
}
}
}
}
}
}
}
catch
(
err
)
{
try
{
}
catch
(
err
)
{
try
{
currentBuild
.
result
=
'FAILED'
_utils
.
beautyEcho
(
err
,
"fail"
)
currentBuild
.
result
=
'FAILED'
_utils
.
beautyEcho
(
err
,
"fail"
)
}
catch
(
err1
)
{
_utils
.
beautyEcho
(
err
,
"fail"
)
}
}
catch
(
err1
)
{
_utils
.
beautyEcho
(
err
,
"fail"
)
}
}
finally
{
sh
"rm -rf ${contextDir}"
_stage
.
clean_images
(
imageTag
)
}
}
}
finally
{
sh
"rm -rf ${contextDir}"
_stage
.
clean_images
(
imageTag
)
}
}
}
}
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