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
2260fdab
Commit
2260fdab
authored
Nov 14, 2017
by
daidekun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixbugs
parent
faf1b432
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
43 deletions
+44
-43
StageBucket.groovy
src/org/qg/StageBucket.groovy
+44
-43
No files found.
src/org/qg/StageBucket.groovy
View file @
2260fdab
// src/org/foo/Stage.groovy
package
org.qg
;
def
debug
()
{
print
"123"
}
class
StageBucket
{
def
debug
()
{
print
"123"
}
def
checkout
(
branchName
,
contextDir
,
gitRepo
)
{
sh
"cp -r /home/quant_group/qg-dockerfiles/templates/ui ${contextDir}"
git
branch:
branchName
,
credentialsId:
'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db'
,
url:
"git@gitabc.xyqb.com:${gitRepo}.git"
sh
"git pull origin master"
}
def
checkout
(
branchName
,
contextDir
,
gitRepo
)
{
sh
"cp -r /home/quant_group/qg-dockerfiles/templates/ui ${contextDir}"
git
branch:
branchName
,
credentialsId:
'e1ccb1ac-1282-4fb4-b766-530ca1a2a2db'
,
url:
"git@gitabc.xyqb.com:${gitRepo}.git"
sh
"git pull origin master"
}
def
build
(
namespace
,
systemName
,
contextDir
)
{
sh
"ansible-playbook /etc/ansible/build.yml -e prefix=${namespace} -e project_name=pre.${systemName} -e workspace=${contextDir} -vv"
}
def
build
(
namespace
,
systemName
,
contextDir
)
{
sh
"ansible-playbook /etc/ansible/build.yml -e prefix=${namespace} -e project_name=pre.${systemName} -e workspace=${contextDir} -vv"
}
def
docker_build_and_push
(
buildNumber
,
branchName
,
harborGroup
,
systemName
,
contextDir
)
{
/*分支名中非法字符统一替换为下划线*/
regex
=
"[`,./;\\[\\]&<>?:\"()|-]+"
safeBranchName
=
branchName
.
replaceAll
(
regex
,
"_"
)
safeSystemName
=
"project"
imageTag
=
"192.168.4.36/${harborGroup}/${systemName}:${safeBranchName}-${buildNumber}"
withDockerServer
([
uri:
"tcp://192.168.4.96:2375/"
])
{
withDockerRegistry
([
credentialsId:
'harbor-qajenkins'
,
url:
"http://192.168.4.36"
])
{
def
image
=
docker
.
build
(
imageTag
,
"--build-arg BUILD_NUMBER=${buildNumber} --build-arg SYSTEM_NAME=${safeSystemName} ${contextDir}"
)
image
.
push
()
def
docker_build_and_push
(
buildNumber
,
branchName
,
harborGroup
,
systemName
,
contextDir
)
{
/*分支名中非法字符统一替换为下划线*/
regex
=
"[`,./;\\[\\]&<>?:\"()|-]+"
safeBranchName
=
branchName
.
replaceAll
(
regex
,
"_"
)
safeSystemName
=
"project"
imageTag
=
"192.168.4.36/${harborGroup}/${systemName}:${safeBranchName}-${buildNumber}"
withDockerServer
([
uri:
"tcp://192.168.4.96:2375/"
])
{
withDockerRegistry
([
credentialsId:
'harbor-qajenkins'
,
url:
"http://192.168.4.36"
])
{
def
image
=
docker
.
build
(
imageTag
,
"--build-arg BUILD_NUMBER=${buildNumber} --build-arg SYSTEM_NAME=${safeSystemName} ${contextDir}"
)
image
.
push
()
}
}
}
echo
"=================镜像地址================="
echo
imageTag
echo
"========================================="
echo
"=================镜像地址================="
echo
imageTag
echo
"========================================="
return
imageTag
}
return
imageTag
}
def
deploy
(
namespace
,
systemName
,
imageTag
,
tier
,
isDeploy
)
{
if
(
isDeploy
)
{
echo
(
"将镜像更新到到Namespace:"
+
namespace
)
build
job:
'deployer.Updater'
,
parameters:
[
string
(
name:
'namespace'
,
value:
"${namespace}"
),
string
(
name:
'name'
,
value:
"${systemName}"
),
string
(
name:
'image'
,
value:
"${imageTag}"
),
string
(
name:
'tier'
,
value:
"${tier}"
)]
}
else
{
echo
"namespace不存在,不执行deploy"
echo
namespace
def
deploy
(
namespace
,
systemName
,
imageTag
,
tier
,
isDeploy
)
{
if
(
isDeploy
)
{
echo
(
"将镜像更新到到Namespace:"
+
namespace
)
build
job:
'deployer.Updater'
,
parameters:
[
string
(
name:
'namespace'
,
value:
"${namespace}"
),
string
(
name:
'name'
,
value:
"${systemName}"
),
string
(
name:
'image'
,
value:
"${imageTag}"
),
string
(
name:
'tier'
,
value:
"${tier}"
)]
}
else
{
echo
"namespace不存在,不执行deploy"
echo
namespace
}
}
}
def
clean
(
contextDir
)
{
sh
"rm -rf ./${contextDir}"
def
clean
(
contextDir
)
{
sh
"rm -rf ./${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