-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDeployment.Jenkinsfile
78 lines (74 loc) · 1.7 KB
/
Deployment.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
podTemplate(yaml: '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: node
image: node:16-buster
resources:
requests:
cpu: "1"
memory: "1Gi"
limits:
cpu: "2"
memory: "4Gi"
command:
- sleep
args:
- 99d
volumeMounts:
- mountPath: /var/jenkins_home
name: build
- name: awscli
image: amazon/aws-cli:2.7.27
resources:
requests:
cpu: "0.5"
memory: "500Mi"
limits:
cpu: "0.5"
memory: "500Mi"
command:
- sleep
args:
- 99d
volumeMounts:
- mountPath: /var/jenkins_home
name: build
volumes:
- name: build
emptyDir: {}
''') {
node(POD_LABEL) {
stage ('Display environment') {
sh 'env'
}
stage('Checkout Code') {
container('node') {
checkout([$class: 'GitSCM', branches: [[name: 'prod']], extensions: [], userRemoteConfigs: [[credentialsId: 'vardyng-github-pat', url: 'https://github.com/VardyNg/Portfolio.git']]])
}
}
stage('Install Dependencies') {
container('node') {
sh '''
npm install
'''
}
}
stage('Build React App') {
container('node') {
sh '''
npm run build
'''
}
}
stage('Sync website to S3') {
container('awscli') {
withAWS(credentials: 'AWS-634042005768', region: 'ap-east-1') {
sh "aws s3 cp ./build s3://vardyng.com --recursive"
sh "aws s3 cp ./build s3://www.vardyng.com --recursive"
}
}
}
}
}