forked from devopshydclub/emartapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
126 lines (106 loc) · 3.64 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
pipeline {
agent any
environment {
clientRegistry = "repository.k8sengineers.com/apexrepo/client"
booksRegistry = "repository.k8sengineers.com/apexrepo/books"
mainRegistry = "repository.k8sengineers.com/apexrepo/main"
registryCredential = 'NexusRepoLogin'
cartRegistry = "https://repository.k8sengineers.com"
}
stages {
stage('Build Angular Image') {
when { changeset "client/*"}
steps {
script {
dockerImage = docker.build( clientRegistry + ":$BUILD_NUMBER", "./client/")
}
}
}
stage('Deploy Angular Image') {
when { changeset "client/*"}
steps{
script {
docker.withRegistry( cartRegistry, registryCredential ) {
dockerImage.push("$BUILD_NUMBER")
dockerImage.push('latest')
}
}
}
}
stage('Kubernetes Deploy Angular') {
when { changeset "client/*"}
steps {
withCredentials([file(credentialsId: 'CartWheelKubeConfig1', variable: 'config')]){
sh """
export KUBECONFIG=\${config}
pwd
helm upgrade kubekart kkartchart --install --set "kkartcharts-frontend.image.client.tag=${BUILD_NUMBER}" --namespace kart
"""
}
}
}
stage('Build books Image') {
when { changeset "javaapi/*"}
steps {
script {
dockerImage = docker.build( booksRegistry + ":$BUILD_NUMBER", "./javaapi/")
}
}
}
stage('Deploy books Image') {
when { changeset "javaapi/*"}
steps{
script {
docker.withRegistry( cartRegistry, registryCredential ) {
dockerImage.push("$BUILD_NUMBER")
dockerImage.push('latest')
}
}
}
}
stage('Kubernetes books Deploy') {
when { changeset "javaapi/*"}
steps {
withCredentials([file(credentialsId: 'CartWheelKubeConfig1', variable: 'config')]){
sh """
export KUBECONFIG=\${config}
pwd
helm upgrade kubekart kkartchart --install --set "kkartcharts-backend.image.books.tag=${BUILD_NUMBER}" --namespace kart
"""
}
}
}
stage('Build Main Image') {
when { changeset "nodeapi/*"}
steps {
script {
sh " sed -i 's/localhost/emongo/g' nodeapi/config/keys.js"
dockerImage = docker.build( mainRegistry + ":$BUILD_NUMBER", "./nodeapi/")
}
}
}
stage('Deploy Main Image') {
when { changeset "nodeapi/*"}
steps{
script {
docker.withRegistry( cartRegistry, registryCredential ) {
dockerImage.push("$BUILD_NUMBER")
dockerImage.push('latest')
}
}
}
}
stage('Kubernetes Main Deploy') {
when { changeset "nodeapi/*"}
steps {
withCredentials([file(credentialsId: 'CartWheelKubeConfig1', variable: 'config')]){
sh """
export KUBECONFIG=\${config}
pwd
helm upgrade kubekart kkartchart --install --set "kkartcharts-backend.image.main.tag=${BUILD_NUMBER}" --namespace kart
"""
}
}
}
}
}