Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
springboot-helloworld
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
kang.li
springboot-helloworld
Commits
4582653a
Commit
4582653a
authored
Jul 11, 2022
by
kang.li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update file
parent
bea364fa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
24 deletions
+25
-24
Jenkinsfile
Jenkinsfile
+25
-24
No files found.
Jenkinsfile
View file @
4582653a
...
...
@@ -2,13 +2,13 @@
def
helmDeploy
(
Map
args
)
{
if
(
args
.
init
){
println
"Helm 初始化"
sh
"helm
init --client-only --stable-repo-url
${args.url}"
sh
"helm
repo add myrepo
${args.url}"
}
else
if
(
args
.
dry_run
)
{
println
"尝试 Helm 部署,验证是否能正常部署"
sh
"helm upgrade --install ${args.name} --namespace ${args.namespace} ${args.values} --set ${
images},${tag} stable
/${args.template} --dry-run --debug"
sh
"helm upgrade --install ${args.name} --namespace ${args.namespace} ${args.values} --set ${
args.image},${args.tag} myrepo
/${args.template} --dry-run --debug"
}
else
{
println
"正式 Helm 部署"
sh
"helm upgrade --install ${args.name} --namespace ${args.namespace} ${args.values} --set ${
images},${tag} stable
/${args.template}"
sh
"helm upgrade --install ${args.name} --namespace ${args.namespace} ${args.values} --set ${
args.image},${args.tag} myrepo
/${args.template}"
}
}
...
...
@@ -20,13 +20,13 @@ timeout(time: 600, unit: 'SECONDS') {
node
(
label
)
{
stage
(
'Git阶段'
){
echo
"Git 阶段"
git
branch:
"master"
,
changelog:
true
,
url:
"http
s://github.com/my-dlq
/springboot-helloworld.git"
git
branch:
"master"
,
changelog:
true
,
url:
"http
://172.8.10.50/kang.li
/springboot-helloworld.git"
}
stage
(
'Maven阶段'
){
echo
"Maven 阶段"
container
(
'maven'
)
{
//这里引用上面设置的全局的 settings.xml 文件,根据其ID将其引入并创建该文件
configFileProvider
([
configFile
(
fileId:
"
75884c5a-4ec2-4dc0-8d87-58b6b1636f
8a"
,
targetLocation:
"settings.xml"
)]){
configFileProvider
([
configFile
(
fileId:
"
f52f21ee-f601-4e6a-89cb-4270f4b275
8a"
,
targetLocation:
"settings.xml"
)]){
sh
"mvn clean install -Dmaven.test.skip=true --settings settings.xml"
}
}
...
...
@@ -38,11 +38,11 @@ timeout(time: 600, unit: 'SECONDS') {
echo
"读取 pom.xml 参数"
pom
=
readMavenPom
file:
'./pom.xml'
// 设置镜像仓库地址
hub
=
"
registry.cn-shanghai.aliyuncs
.com"
hub
=
"
harbor.siger-data
.com"
// 设置仓库项目名
project_name
=
"
mydlq
"
project_name
=
"
test
"
echo
"编译 Docker 镜像"
docker
.
withRegistry
(
"http://${hub}"
,
"
ffb3b544-108e-4851-b747-b8a00bfe7ee0
"
)
{
docker
.
withRegistry
(
"http://${hub}"
,
"
4010cced-1d9c-42df-b3d3-d868c67920b6
"
)
{
echo
"构建镜像"
// 设置推送到aliyun仓库的mydlq项目下,并用pom里面设置的项目名与版本号打标签
def
customImage
=
docker
.
build
(
"${hub}/${project_name}/${pom.artifactId}:${pom.version}"
)
...
...
@@ -55,25 +55,26 @@ timeout(time: 600, unit: 'SECONDS') {
}
stage
(
'Helm阶段'
){
container
(
'helm-kubectl'
)
{
withKubeConfig
([
credentialsId:
"8
510eda6-e1c7-4535-81af-17626b9575f
7"
,
serverUrl:
"https://kubernetes.default.svc.cluster.local"
])
{
withKubeConfig
([
credentialsId:
"8
8c5b7aa-60f3-4d74-911e-a0183baeb09
7"
,
serverUrl:
"https://kubernetes.default.svc.cluster.local"
])
{
// 设置参数
images
=
"image.repository=${hub}/${project_name}/${pom.artifactId}"
tag
=
"image.tag=${pom.version}"
template
=
"spring-boot"
repo_url
=
"http://chart.mydlq.club"
app_name
=
"${pom.artifactId}"
// 检测是否存在yaml文件
def
values
=
""
if
(
fileExists
(
'values.yaml'
))
{
values
=
"-f values.yaml"
}
// 执行 Helm 方法
image
=
"image.repository=${hub}/${project_name}/${pom.artifactId}"
tag
=
"image.tag=${pom.version}"
// 设置使用的 chart 并指定版本
template
=
"spring-boot --version 2.0.2"
repo_url
=
"http://172.8.10.66/charts"
app_name
=
"${pom.artifactId}"
// 检测是否存在yaml文件
def
values
=
""
if
(
fileExists
(
'values.yaml'
))
{
values
=
"-f values.yaml"
}
// 执行 Helm 方法
echo
"Helm 初始化"
helmDeploy
(
init:
true
,
url:
"${repo_url}"
);
echo
"Helm 执行部署测试"
helmDeploy
(
init:
false
,
dry_run:
true
,
name:
"${app_name}"
,
namespace:
"
mydlqcloud"
,
image:
"${images
}"
,
tag:
"${tag}"
,
values:
"${values}"
,
template:
"${template}"
)
helmDeploy
(
init:
false
,
dry_run:
true
,
name:
"${app_name}"
,
namespace:
"
siger-test"
,
image:
"${image
}"
,
tag:
"${tag}"
,
values:
"${values}"
,
template:
"${template}"
)
echo
"Helm 执行正式部署"
helmDeploy
(
init:
false
,
dry_run:
false
,
name:
"${app_name}"
,
namespace:
"
mydlqcloud"
,
image:
"${images
}"
,
tag:
"${tag}"
,
values:
"${values}"
,
template:
"${template}"
)
helmDeploy
(
init:
false
,
dry_run:
false
,
name:
"${app_name}"
,
namespace:
"
siger-test"
,
image:
"${image
}"
,
tag:
"${tag}"
,
values:
"${values}"
,
template:
"${template}"
)
}
}
}
...
...
@@ -88,10 +89,10 @@ timeout(time: 600, unit: 'SECONDS') {
stage
(
'email'
){
if
(
currResult
==
'SUCCESS'
)
{
echo
"发送成功邮件"
emailext
(
subject:
'任务执行成功'
,
to:
'
3*****7@qq
.com'
,
body:
'''任务已经成功构建完成...'''
)
emailext
(
subject:
'任务执行成功'
,
to:
'
kang.li@siger-data
.com'
,
body:
'''任务已经成功构建完成...'''
)
}
else
{
echo
"发送失败邮件"
emailext
(
subject:
'任务执行失败'
,
to:
'
3*****7@qq
.com'
,
body:
'''任务执行失败构建失败...'''
)
emailext
(
subject:
'任务执行失败'
,
to:
'
kang.li@siger-data
.com'
,
body:
'''任务执行失败构建失败...'''
)
}
}
}
...
...
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