generated from CS3219-AY2324S1/course-assessment-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
140 lines (119 loc) · 4.32 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
127
128
129
130
131
132
133
134
135
136
137
138
139
//sample push
pipeline {
environment{
customImage = ""
}
agent any
tools {nodejs "nodejs"}
// agent {
// kubernetes {
// defaultContainer 'node' // Default container name
// yaml '''
// apiVersion: v1
// kind: Pod
// spec:
// containers:
// - name: node
// image: node:18
// command:
// - cat
// tty: true
// '''
// }
// }
stages {
stage('Clone Repository') {
steps {
checkout scm
}
}
stage('Build History Service') {
steps {
sh '''
# Navigate to your Node.js app directory
cd history-service
# Install dependencies
npm install
# Build your Node.js application
npm run build
'''
}
}
stage('Build Questions Service') {
steps {
sh '''
# Navigate to your Node.js app directory
cd questions-service
# Install dependencies
npm install
# Build your Node.js application
npm run build
'''
}
}
// stage('Build Frontend') {
// steps {
// sh '''
// # Navigate to your Node.js app directory
// cd frontend
// # Install dependencies
// npm install
// # Build your Node.js application
// npm run build
// '''
// }
// }
stage('Build History Docker Image') {
steps {
// Inside the 'node' container
dir('history-service') {
// Change the working directory to 'history-service'
script {
// Execute your Docker build command here
customImage = docker.build("yuehern/history-service:${env.BUILD_ID}")
}
}
// dir('questions-service') {
// // Change the working directory to 'history-service'
// script {
// // Execute your Docker build command here
// customImage = docker.build("questions-service:${env.BUILD_ID}")
// }
// }
}
}
stage('Build Questions Docker Image') {
steps {
// Inside the 'node' container
dir('questions-service') {
// Change the working directory to 'history-service'
script {
// Execute your Docker build command here
customImage = docker.build("yuehern/questions-service:${env.BUILD_ID}")
}
}
}
}
// stage("Pushing Application Docker Image to Google Artifact Registry"){
// steps{
// script{
// sh'''
// gcloud auth configure-docker asia-southeast1-docker.pkg.dev
// docker push asia-southeast1-docker.pkg.dev/astral-shape-402017/history-service:${env.BUILD_ID}
// '''
// }
// }
// }
// stage('Authenticate with Google Cloud') {
// steps {
// script {
// sh "gcloud auth configure-docker asia-southeast1-docker.pkg.dev"
// // sh "docker tag history-service:${env.BUILD_ID} asia-southeast1-docker.pkg.dev/astral-shape-402017/cs3219/history-service:${env.BUILD_ID}"
// sh "docker tag history-service:${env.BUILD_ID} yuehern/history-service:${env.BUILD_ID}"
// // sh "docker push asia-southeast1-docker.pkg.dev/astral-shape-402017/cs3219/history-service:${env.BUILD_ID}"
// // sh "docker push yuehern/history-service:${env.BUILD_ID}"
// }
// }
// }
}
}