forked from LondheShubham153/tws-e-commerce-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
124 lines (111 loc) · 3.8 KB
/
Jenkinsfile
File metadata and controls
124 lines (111 loc) · 3.8 KB
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
@Library('Shared') _
pipeline {
agent any
environment {
// Update the main app image name to match the deployment file
DOCKER_IMAGE_NAME = 'trainwithshubham/easyshop-app'
DOCKER_MIGRATION_IMAGE_NAME = 'trainwithshubham/easyshop-migration'
DOCKER_IMAGE_TAG = "${BUILD_NUMBER}"
GITHUB_CREDENTIALS = credentials('github-credentials')
GIT_BRANCH = "master"
}
stages {
stage('Cleanup Workspace') {
steps {
script {
clean_ws()
}
}
}
stage('Clone Repository') {
steps {
script {
clone("https://github.com/LondheShubham153/tws-e-commerce-app.git","master")
}
}
}
stage('Build Docker Images') {
parallel {
stage('Build Main App Image') {
steps {
script {
docker_build(
imageName: env.DOCKER_IMAGE_NAME,
imageTag: env.DOCKER_IMAGE_TAG,
dockerfile: 'Dockerfile',
context: '.'
)
}
}
}
stage('Build Migration Image') {
steps {
script {
docker_build(
imageName: env.DOCKER_MIGRATION_IMAGE_NAME,
imageTag: env.DOCKER_IMAGE_TAG,
dockerfile: 'scripts/Dockerfile.migration',
context: '.'
)
}
}
}
}
}
stage('Run Unit Tests') {
steps {
script {
run_tests()
}
}
}
stage('Security Scan with Trivy') {
steps {
script {
// Create directory for results
trivy_scan()
}
}
}
stage('Push Docker Images') {
parallel {
stage('Push Main App Image') {
steps {
script {
docker_push(
imageName: env.DOCKER_IMAGE_NAME,
imageTag: env.DOCKER_IMAGE_TAG,
credentials: 'docker-hub-credentials'
)
}
}
}
stage('Push Migration Image') {
steps {
script {
docker_push(
imageName: env.DOCKER_MIGRATION_IMAGE_NAME,
imageTag: env.DOCKER_IMAGE_TAG,
credentials: 'docker-hub-credentials'
)
}
}
}
}
}
// Add this new stage
stage('Update Kubernetes Manifests') {
steps {
script {
update_k8s_manifests(
imageTag: env.DOCKER_IMAGE_TAG,
manifestsPath: 'kubernetes',
gitCredentials: 'github-credentials',
gitUserName: 'Jenkins CI',
gitUserEmail: 'shubhamnath5@gmail.com'
)
}
}
}
}
}