mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-12-27 10:57:28 +00:00
Create jenkinsfile_v2
Signed-off-by: eunyoung1111 <blahblah_y@naver.com>
This commit is contained in:
parent
145b609595
commit
99e4111142
1 changed files with 55 additions and 0 deletions
55
jenkinsfile_v2
Normal file
55
jenkinsfile_v2
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
pipeline {
|
||||
agent {
|
||||
kubernetes {
|
||||
label 'kaniko-maven'
|
||||
defaultContainer 'maven'
|
||||
}
|
||||
}
|
||||
|
||||
environment {
|
||||
IMAGE = "wodnr8174/spring-petclinic"
|
||||
TAG = "${BUILD_NUMBER}"
|
||||
KUBECONFIG_CRED = "kubeconfig"
|
||||
}
|
||||
|
||||
stages {
|
||||
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
checkout scm
|
||||
}
|
||||
}
|
||||
|
||||
stage('Maven Build') {
|
||||
steps {
|
||||
container('maven') {
|
||||
sh 'mvn clean package -DskipTests'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Docker Image') {
|
||||
steps {
|
||||
container('kaniko') {
|
||||
sh """
|
||||
/kaniko/executor \
|
||||
--dockerfile=Dockerfile \
|
||||
--context=`pwd` \
|
||||
--destination=$IMAGE:latest \
|
||||
--destination=$IMAGE:$TAG
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy to Kubernetes') {
|
||||
steps {
|
||||
withCredentials([file(credentialsId: KUBECONFIG_CRED, variable: 'KUBECONFIG')]) {
|
||||
sh """
|
||||
kubectl --kubeconfig=$KUBECONFIG set image deployment/petclinic petclinic=$IMAGE:$TAG -n petclinic
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue