Create jenkinsfile_v2

Signed-off-by: eunyoung1111 <blahblah_y@naver.com>
This commit is contained in:
eunyoung1111 2025-12-08 16:30:43 +09:00 committed by GitHub
parent 145b609595
commit 99e4111142
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

55
jenkinsfile_v2 Normal file
View 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
"""
}
}
}
}
}