-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsFile
74 lines (72 loc) · 2.74 KB
/
JenkinsFile
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
pipeline {
environment {
dockerimagebe = 'auroobaparker/backend-image'
dockerImageBackend = ""
dockerimagefe = 'auroobaparker/frontend-image'
dockerImageFrontend = ""
registryCredential = '75414fc1-41f1-4690-a367-63bcadaa39a0'
kubeconfigSecret = 'cubesecret'
kubeconfigPath = 'C:/Users/AuroobaParker/.kube/config'
}
agent any
stages {
stage('Build Docker Images') {
steps {
echo 'Building Docker Image...'
script {
dockerImageBackend = docker.build("${dockerimagebe}","./Thrift_Store")
dockerImageFrontend = docker.build("${dockerimagefe}","./react-tutorial")
}
}
}
stage('Push Docker Images') {
environment {
registryCredential = 'dockercreds'
}
steps {
echo 'Pushing Docker Image...'
script {
docker.withRegistry( '', registryCredential) {
dockerImageBackend.push("latest")
dockerImageFrontend.push("latest")
}
}
}
}
stage('minikube config') {
steps {
echo 'Starting minikube...'
bat 'minikube delete'
bat "docker context use default"
bat 'minikube config set driver docker'
bat 'minikube start --driver docker'
powershell 'minikube docker-env | Invoke-Expression'
bat 'minikube status'
}
}
stage('deploy on Kubernetes') {
steps {
echo 'Deploying on kubernetes'
bat "kubectl apply -f ./Kubernetes/mongo-deployment.yaml --validate=false"
bat "kubectl apply -f ./Kubernetes/backend-deployment.yaml --validate=false"
bat "kubectl apply -f ./Kubernetes/frontend-deployment.yaml --validate=false"
}
}
stage('Port forwarding...') {
steps{
echo 'port forwarding task being done'
echo 'frontend will be running on port 3000!'
bat 'start cmd /c kubectl port-forward service/backend 5000:5000'
bat 'start cmd /c kubectl port-forward service/frontend 3000:3000'
}
}
}
post {
success {
echo 'Build successful!'
}
failure {
echo 'Build failed!'
}
}
}