-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
152 lines (133 loc) · 4.4 KB
/
azure-pipelines.yml
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
140
141
142
143
144
145
146
147
148
149
150
151
152
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: BuildAndAnalyze
jobs:
- job: BuildClient
displayName: 'Build Client'
steps:
- task: NodeTool@0
inputs:
versionSpec: '14.x'
displayName: 'Install Node.js (Client)'
- script: |
cd client
npm install
displayName: 'npm install (Client)'
- script: |
cd client
npm run lint > eslint-report-client.txt
displayName: 'npm run lint (Client)'
- task: PublishBuildArtifacts@1
displayName: 'Publish ESLint Report (Client)'
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/client/eslint-report-client.txt'
ArtifactName: 'eslint-report-client'
- script: |
cd client
npm run build
displayName: 'npm run built (Client)'
- task: CopyFiles@2
displayName: 'Copy Frontend Code'
inputs:
SourceFolder: '$(Build.SourcesDirectory)/client'
Contents: |
**/*
!node_modules/**/*
TargetFolder: '$(Build.ArtifactStagingDirectory)/client'
- task: PublishBuildArtifacts@1
displayName: 'Publish Client Artifact'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/client'
ArtifactName: 'client'
- task: Docker@2
inputs:
containerRegistry: 'dockerhub'
repository: 'farazkhawaja/frontend'
command: 'build'
Dockerfile: 'client/Dockerfile'
displayName: DockerBuild
- script: |
sudo apt-get install rpm
wget https://github.com/aquasecurity/trivy/releases/download/v0.46.0/trivy_0.46.0_Linux-64bit.deb
sudo dpkg -i trivy_0.46.0_Linux-64bit.deb
displayName: 'Install Trivy'
- script: |
trivy -v
trivy image --format table farazkhawaja/frontend:$(Build.BuildId) | tee /tmp/trivy_scan.txt
displayName: 'Scan Docker Image'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '/tmp/trivy_scan.txt'
ArtifactName: 'TrivyScanResults'
publishLocation: 'Container'
displayName: 'Publish Trivy Scan Results'
- task: Docker@2
inputs:
containerRegistry: 'dockerhub'
repository: 'farazkhawaja/frontend'
command: 'push'
- job: BuildServer
displayName: 'Build Server'
steps:
- task: NodeTool@0
inputs:
versionSpec: '14.x'
displayName: 'Install Node.js (Server)'
- script: |
cd server
npm install
displayName: 'npm install (Server)'
- script: |
cd server
npm run lint > eslint-report-server.txt
displayName: 'npm run lint (Server)'
- task: PublishBuildArtifacts@1
displayName: 'Publish ESLint Report (Server)'
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/server/eslint-report-server.txt'
ArtifactName: 'eslint-report-server'
- task: CopyFiles@2
displayName: 'Copy Backend Code'
inputs:
SourceFolder: '$(Build.SourcesDirectory)/server'
Contents: |
**/*
!node_modules/**/*
TargetFolder: '$(Build.ArtifactStagingDirectory)/backend'
- task: PublishBuildArtifacts@1
displayName: 'Publish Backend Artifact (Server)'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/backend'
ArtifactName: 'backend-server'
- task: Docker@2
inputs:
containerRegistry: 'dockerhub'
repository: 'farazkhawaja/backend'
command: 'build'
Dockerfile: 'server/Dockerfile'
- task: Docker@2
inputs:
containerRegistry: 'dockerhub'
repository: 'farazkhawaja/backend'
command: 'push'
- job: HelmInstall
dependsOn:
- BuildClient
- BuildServer
steps:
- task: HelmInstaller@0
inputs:
helmVersion: '2.14.1'
installKubectl: true
- task: HelmDeploy@0
inputs:
command: 'package'
chartPath: 'client/helm-client'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifact: 'helm-package'
publishLocation: 'pipeline'