-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkinsfile.txt
46 lines (42 loc) · 1.56 KB
/
jenkinsfile.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
pipeline {
agent any
stages {
stage('Clone repository') {
steps {
git branch: 'main', credentialsId: 'f5616a59-57bf-4fde-8837-330e9739a41a', url: 'https://github.com/kabha/CouponService.git'
}
}
stage('package source code') {
steps {
// Run Maven clean install to package a jar from the source code
sh 'mvn clean install'
}
}
stage('Build Docker Image') {
steps {
// Build Docker image from the coupon Jar
sh 'docker build -t kabhad82/coupon-services:v1.2 .'
}
}
stage('Push Docker image to registry') {
steps {
withCredentials([string(credentialsId: 'dockerhub-pwd', variable: 'dockerHubPwd')]) {
// Login to Docker Hub
sh 'docker login -u kabhad82 -p ${dockerHubPwd}'
// Push Docker image
sh "docker push kabhad82/coupon-services:v1.2"
}
}
}
stage('Deploy to Kubernetes') {
steps {
sh 'kubectl apply -f mysql-secret.yaml'
sh 'kubectl apply -f mysql-configmap.yaml'
sh 'kubectl apply -f mysql-statefulset.yaml'
sh 'kubectl apply -f mysql-service.yaml'
sh 'kubectl apply -f coupon-deployment.yaml'
sh 'kubectl apply -f coupon-service.yaml'
}
}
}
}