-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
109 lines (97 loc) · 3.29 KB
/
Copy pathJenkinsfile
File metadata and controls
109 lines (97 loc) · 3.29 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
@Library('Shared') _
pipeline {
agent any
environment {
// Update the main app image name to match the deployment file
DOCKER_IMAGE_NAME = 'fendimohamed/easyshop-app'
DOCKER_MIGRATION_IMAGE_NAME = 'fendimohamed/easyshop-migration'
DOCKER_IMAGE_TAG = "${BUILD_NUMBER}"
GITHUB_CREDENTIALS = credentials('github-credentials')
GIT_BRANCH = "main"
}
stages {
stage('Cleanup Workspace') {
steps {
script {
clean_ws()
}
}
}
stage('Clone Repository') {
steps {
script {
clone("https://github.com/FendiMohamed/nextjs-eks-infra-observability.git","main")
}
}
}
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'
)
}
}
}
}
}
}
}