-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
123 lines (117 loc) · 3.77 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
trigger:
- main
variables:
- group: azure-function-testing-concept
jobs:
- job: BuildBicep
pool:
vmImage: ubuntu-latest
steps:
- task: AzureCLI@2
displayName: 'Build bicep artifact'
inputs:
azureSubscription: $(azureResourceManagerConnection)
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: 'az bicep build --file function.bicep'
- task: RunARMTTKTestsXPlat@1
inputs:
templatelocation: '$(System.DefaultWorkingDirectory)/function.bicep'
resultLocation: '$(System.DefaultWorkingDirectory)/results/'
- task: PublishTestResults@2
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: '$(System.DefaultWorkingDirectory)/results/*-armttk.xml'
condition: always()
- task: PublishBuildArtifacts@1
displayName: 'Publish bicep artifact'
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/function.json'
ArtifactName: 'finishedTemplate'
publishLocation: 'Container'
- job: BuildFunction
pool:
vmImage: ubuntu-latest
dependsOn: BuildBicep
steps:
- task: DotNetCoreCLI@2
displayName: Build solution
inputs:
command: 'build'
arguments: '--configuration Release'
- task: DotNetCoreCLI@2
displayName: 'Publish to output folder'
inputs:
command: 'publish'
publishWebProjects: false
projects: 'src/http-function/http-function.csproj'
arguments: '--configuration Release --output publish_output'
zipAfterPublish: false
modifyOutputPath: false
- task: ArchiveFiles@2
displayName: "Archive output folder"
inputs:
rootFolderOrFile: "$(System.DefaultWorkingDirectory)/publish_output"
includeRootFolder: false
archiveFile: "$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip"
- task: PublishBuildArtifacts@1
displayName: 'Publish archive'
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip'
ArtifactName: 'drop'
publishLocation: 'Container'
- deployment: Deploy
pool:
vmImage: ubuntu-latest
environment: dev
dependsOn: BuildFunction
strategy:
runOnce:
deploy:
steps:
- task: AzureCLI@2
displayName: 'Deploy Azure Function Bicep'
inputs:
azureSubscription: $(azureResourceManagerConnection)
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
az --version
az deployment group create --resource-group $(resourceGroup) --template-file $(Agent.BuildDirectory)/finishedTemplate/function.json --parameters appName='$(functionAppName)'
- task: AzureFunctionApp@1
displayName: 'Deploy Package to Azure Function'
inputs:
azureSubscription: "$(azureResourceManagerConnection)"
appType: "functionAppLinux"
appName: "$(functionAppName)"
package: "$(Agent.BuildDirectory)/**/*.zip"
- job: Poke
pool: server
dependsOn: Deploy
steps:
- task: AzureFunction@1
inputs:
function: $(functionTestUrl)
key: $(functionKey)
method: 'GET'
queryParameters: 'name=John'
- job: Test
pool:
vmImage: ubuntu-latest
dependsOn: Poke
steps:
- task: Bash@3
displayName: 'Run Newman Tests'
continueOnError: true
inputs:
targetType: 'inline'
script: |
npm install -g newman
newman run '$(Build.SourcesDirectory)/tests/Azure Function Testing Concept.postman_collection.json' --env-var 'baseUrl=$(appBaseUrl)' --reporters cli,junit --reporter-junit-export junit-report.xml
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/*.xml'
mergeTestResults: true
failTaskOnFailedTests: true