This repository has been archived by the owner on Jun 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-ci-cd.yml
81 lines (69 loc) · 2.68 KB
/
azure-ci-cd.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
# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- master
pr: none
pool: Default
jobs:
- job: CICD
steps:
- task: NodeTool@0
inputs:
versionSpec: "15.x"
displayName: "Install Node.js"
- task: Npm@1
displayName: Installing app dependencies
inputs:
command: "install"
workingDir: "app"
- task: Npm@1
displayName: Build app
inputs:
command: "custom"
workingDir: "app"
customCommand: "run build"
- task: Npm@1
displayName: Testing app
inputs:
command: "custom"
workingDir: "app"
customCommand: "test"
- task: CmdLine@2
displayName: Sonar scanner on app
inputs:
script: |
export SONAR_SCANNER_VERSION=4.4.0.2170
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"
cd app/
sonar-scanner \
-Dsonar.organization=pathfinder \
-Dsonar.projectKey=StudentRun \
-Dsonar.sources=. \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.login=$(SONARLOGIN) \
-Dsonar.testExecutionReportPaths=test-report.xml \
-Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info \
-Dsonar.coverage.exclusions=\*\*/__tests__/\*\*,\*\*/config/\*\*,jest.config.js,\*\*/server.js,public/js/module.js,__tests__/,public/js/game.js,public/js/join.js,public/js/game/GameScene.js,public/js/view/gameViewController.js,public/js/view/joinViewController.js \
-Dsonar.exclusions=\*\*/__tests__/\*\*,
- task: CopyFilesOverSSH@0
displayName: Copy app to server
inputs:
sshEndpoint: "PSIT Server"
contents: "**"
targetFolder: "/opt/studentRun/"
readyTimeout: "20000"
cleanTargetFolder: true
- task: SSH@0
displayName: Restart service on server
inputs:
sshEndpoint: "PSIT Server"
runOptions: "commands"
commands: "sudo systemctl restart studentrun.service"
readyTimeout: "20000"
interactiveSession: true