Repository navigation
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
123 lines (112 loc) · 4.49 KB
/
Copy pathazure-pipelines.yml
File metadata and controls
123 lines (112 loc) · 4.49 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
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
# Node.js with Angular
# Build a Node.js project that uses Angular.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- master
- develop
- rl* # release branches to be built should be named rl[insertSemverHere]
#- ft* # feature branches to be built should be named ft[insertSemverHere]
- hf* # hotfix branches to be built should be named hf[insertSemverHere]
pool:
vmImage: 'windows-2019'
variables:
${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
appName: "pr$(System.PullRequest.PullRequestNumber)"
${{ if not(eq(variables['Build.Reason'], 'PullRequest')) }}:
appName: "$(Build.SourceBranchName)"
${{ if eq(variables['Build.SourceBranchName'], 'master') }}: # only works if you have a master branch
envName: "preproduction"
${{ if eq(variables['Build.SourceBranchName'], 'develop') }}: # only works if you have a develop branch
envName: "nonproduction"
${{ if contains(variables['Build.SourceBranchName'], 'ft') }}: # only works if you have a feature branch
envName: "nonproduction"
${{ if contains(variables['Build.SourceBranchName'], 'merge') }}: # only works if you have a PR branch
envName: "nonproduction"
${{ if contains(variables['Build.SourceBranchName'], 'rl') }}: # only works if you have a release branch
envName: "production"
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
npm install
displayName: 'Install dependencies'
- script: |
npm test
displayName: 'run unit and integration tests'
- script: |
./node_modules/.bin/webdriver-manager update --versions.chrome=83.0.4103.39
displayName: 'add chrome driver to node directory'
condition: |
or(
eq(variables['Build.Reason'], 'PullRequest'),
eq(variables['Build.SourceBranch'], 'refs/heads/master'),
eq(variables['Build.SourceBranch'], 'refs/heads/develop')
)
- script: |
npm run-script e2e
displayName: 'run end-to-end tests'
condition: |
or(
eq(variables['Build.Reason'], 'PullRequest'),
eq(variables['Build.SourceBranch'], 'refs/heads/master'),
eq(variables['Build.SourceBranch'], 'refs/heads/develop')
)
- script: |
npm run-script lint
displayName: 'run linting'
condition: |
or(
eq(variables['Build.Reason'], 'PullRequest'),
eq(variables['Build.SourceBranch'], 'refs/heads/master'),
eq(variables['Build.SourceBranch'], 'refs/heads/develop')
)
- script: |
npm run-script build -- --configuration=$(envName)
displayName: 'npm build'
- task: CopyFiles@2
displayName: 'Copy Build Artifacts to Staging Directory'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)/dist/admin-web-ui'
Contents: |
**
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: AzureCLI@2
displayName: 'Create Container for Build Artefacts in Storage Account'
inputs:
azureSubscription: math-dojo-admin-ui-pipeline
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
$accountNameExists = az storage account check-name --name adminuibuild$(appName) --subscription 5594cd6c-b674-4323-8517-5e859a399468 | ConvertFrom-Json
Write-Host "Does the account name exist for adminuibuild$(appName): $accountNameExists"
If ($accountNameExists.nameAvailable) {
try {
az storage account create --name adminuibuild$(appName) --kind StorageV2 --location uksouth --resource-group math-dojo-hzprod-admin-ui --subscription 5594cd6c-b674-4323-8517-5e859a399468
}
catch {
Write-Host "An error occurred:"
Write-Host $_
}
}
az storage blob service-properties update --account-name adminuibuild$(appName) --static-website --index-document index.html --404-document index.html --auth-mode login
- task: AzureFileCopy@3
displayName: 'Copy Build Artifacts to Blob Storage'
inputs:
sourcePath: '$(Build.ArtifactStagingDirectory)'
azureSubscription: math-dojo-admin-ui-pipeline
destination: AzureBlob
storage: 'adminuibuild$(appName)'
containerName: $web
copyFilesInParallel: true
cleanTargetBeforeCopy: true
- task: AzureCLI@2
displayName: 'Show url for stored blob contents'
inputs:
azureSubscription: math-dojo-admin-ui-pipeline
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
az storage account show -n adminuibuild$(appName) -g math-dojo-hzprod-admin-ui --query "primaryEndpoints.web" --output tsv