Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
springboot-k8s-example
Project
Project
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
demo
springboot-k8s-example
Commits
59346074
Commit
59346074
authored
Jun 17, 2020
by
卢浩元
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Jenkinsfile-withCredentials
parent
e4d99eb3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
0 deletions
+81
-0
Jenkinsfile-withCredentials
jenkins/Jenkinsfile-withCredentials
+81
-0
No files found.
jenkins/Jenkinsfile-withCredentials
0 → 100644
View file @
59346074
#
!
/usr/
bin
/
env
groovy
def
projectProperties
=
[
[
$class
:
'BuildDiscarderProperty'
,
strategy:
[
$class
:
'LogRotator'
,
numToKeepStr:
'5'
]],
parameters
([
string
(
name:
'REGISTRY_URL'
,
defaultValue:
'harbor.poc.paas.com'
,
description:
'docker仓库地址'
)
])
]
properties
(
projectProperties
)
podTemplate
(
cloud:
'kubernetes'
,
containers:
[
containerTemplate
(
name:
'maven'
,
image:
'harbor.k2software.com.cn/build/maven:3.6.0-jdk-8'
,
command:
'cat'
,
ttyEnabled:
true
),
containerTemplate
(
name:
'docker'
,
image:
'harbor.k2software.com.cn/build/docker:latest'
,
command:
'cat'
,
ttyEnabled:
true
),
containerTemplate
(
name:
'kubectl'
,
image:
'harbor.k2software.com.cn/build/k8s-kubectl:v1.14.0'
,
command:
'cat'
,
ttyEnabled:
true
)
],
volumes:
[
hostPathVolume
(
hostPath:
'/var/run/docker.sock'
,
mountPath:
'/var/run/docker.sock'
),
hostPathVolume
(
hostPath:
'/root/.kube'
,
mountPath:
'/root/.kube'
),
hostPathVolume
(
hostPath:
'/root/.m2'
,
mountPath:
'/root/.m2'
)
],
annotations:
[
podAnnotation
(
key:
"sidecar.istio.io/inject"
,
value:
"false"
)
]
)
{
node
(
POD_LABEL
)
{
def
gitCommit
def
shortGitCommit
def
previousGitCommit
container
(
'maven'
)
{
stage
(
'checkout'
)
{
checkout
scm
sh
'printenv'
gitCommit
=
sh
(
script:
"git rev-parse HEAD"
,
returnStdout:
true
).
trim
()
shortGitCommit
=
"${gitCommit[0..10]}"
previousGitCommit
=
sh
(
script:
"git rev-parse ${gitCommit}~"
,
returnStdout:
true
)
echo
"gitCommit = ${gitCommit}"
echo
"shortGitCommit = ${shortGitCommit}"
echo
"previousGitCommit = ${previousGitCommit}"
}
stage
(
'pacakge'
)
{
sh
'mvn clean package -Dmaven.test.skip=true -s ./settings.xml'
}
}
container
(
'docker'
)
{
stage
(
'docker'
)
{
withCredentials
([
usernamePassword
(
credentialsId:
'REGISTRY_URL'
,
passwordVariable:
'DOCKER_PASSWORD'
,
usernameVariable:
'DOCKER_USER'
)])
{
sh
"docker login -u ${DOCKER_USER} -p ${DOCKER_PASSWORD} ${params.REGISTRY_URL}"
sh
"docker build . -t ${params.REGISTRY_URL}/demo/k8s-example:${shortGitCommit}"
sh
"docker push ${params.REGISTRY_URL}/demo/k8s-example:${shortGitCommit}"
}
sh
"docker rmi ${params.REGISTRY_URL}/demo/k8s-example:${shortGitCommit}"
}
}
//container('kubectl') {
// stage('k8s deploy') {
// sh "sed -i \"s/lusyoe\\/k8s-example/${params.REGISTRY_URL}\\/demo\\/k8s-example:${shortGitCommit}/g\" k8s-example.yaml"
// sh "kubectl --kubeconfig=/root/.kube/config apply -f k8s-example.yaml"
// }
//}
}
}
// vim: ft=groovy
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