-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDev-Build.Jenkinsfile
More file actions
80 lines (78 loc) · 2.1 KB
/
Dev-Build.Jenkinsfile
File metadata and controls
80 lines (78 loc) · 2.1 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
pipeline {
agent {
kubernetes {
cloud 'home-kubernetes'
yaml '''
apiVersion: v1
kind: Pod
spec:
nodeSelector:
kubernetes.io/os: linux
kubernetes.io/arch: arm64
containers:
- name: node
image: node:16.17-alpine3.15
resources:
limits:
cpu: "2"
memory: "2Gi"
command:
- sleep
args:
- 99d
volumeMounts:
- mountPath: /var/jenkins_home
name: build
- name: azurecli
image: vardyng/azure-cli:latest
resources:
limits:
cpu: "1"
memory: "1Gi"
command:
- sleep
args:
- 99d
volumeMounts:
- mountPath: /var/jenkins_home
name: build
volumes:
- name: build
emptyDir: {}
'''
}
}
stages {
stage('Authendicate azure cli') {
steps {
container('azurecli') {
withCredentials([azureServicePrincipal('azure-vardyng1999-gmail-com')]) {
sh 'env'
sh 'az login --service-principal -u $AZURE_CLIENT_ID -p $AZURE_CLIENT_SECRET -t $AZURE_TENANT_ID'
}
}
}
}
stage('Build React App') {
steps {
container('node') {
checkout([$class: 'GitSCM', branches: [[name: 'dev']], extensions: [], userRemoteConfigs: [[credentialsId: 'vardyng-github-pat', url: 'https://github.com/VardyNg/Portfolio.git']]])
sh '''
echo "SOURCE_BRANCH_NAME: $SOURCE_BRANCH_NAME"
npm install --legacy-peer-deps
npm run build
'''
}
}
}
stage('Deploy to Azure Blob Storage') {
steps {
container('azurecli') {
withCredentials([azureServicePrincipal('azure-vardyng1999-gmail-com')]) {
sh 'az storage blob upload-batch -d \'$web\' -s build --account-name devportfiliosa --overwrite'
}
}
}
}
}
}