-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yaml
126 lines (119 loc) · 4.37 KB
/
azure-pipelines.yaml
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
# Azure DevOps YAML Pipeline from Bow Data Toolkits
trigger:
branches:
include:
- "*"
resources:
repositories:
- repository: bowdata-toolkits
type: git
name: toolkits/bowdata.toolkits.azure-pipelines
ref: refs/heads/master
parameters:
- name: workingDirectory
default: $(Build.SourcesDirectory)
- name: preRelease
default: "-a"
- name: logLevel
default: DEBUG
type: string
displayName: "Log Level"
values:
- DEBUG
- INFO
- WARNING
- ERROR
- CRITICAL
- name: azureDockerStageCondition
default: succeeded()
- name: azureDockerStageName
default: AzureDockerStage
- name: azureDockerStageDependsOn
type: object
default: ['Build']
- name: versionStageDependsOn
type: object
default: ['AzureDockerStage']
- name: dockerhubServiceConnection
default: "bd-docker-hub-svc-connection"
- name: dockerhubRepository # this defaults to the same value as parameters.appName
default: $(Build.Repository.Name)
- name: dockerhubAccount
default: "bowdatadockerhub"
- name: containerPort
default: 5000
# application specific params
- name: appName
default: $(Build.Repository.Name)
- name: buildTag
default: $(Build.BuildId)
- name: hostPort
default: 8000
# Parameter Sets
- name: _ignore_params
type: object
default:
- dockerRunCommand
- dockerRunPostSteps
- name: _general_params
type: object
default:
- logLevel
- workingDirectory
- name: _azure_docker_stage_params
type: object
default:
- azureDockerStageName
- azureDockerStageCondition
- azureDockerStageDependsOn
- dockerhubServiceConnection
- containerPort
- containerRuntimeVariables
- dockerhubAccount
- dockerhubRepository
stages:
- template: /python/pipelines/package-pipeline.yaml@bowdata-toolkits
parameters:
versionStageDependsOn: ${{parameters.versionStageDependsOn}}
preRelease: ${{parameters.preRelease}}
logLevel: ${{parameters.logLevel}}
workingDirectory: ${{parameters.workingDirectory}}
integrationTestStages:
# docker image build, test & push stage on Azure agent
- template: /containers/stages/azure-docker-stage.yaml@bowdata-toolkits
parameters:
${{ each pair in parameters }}:
${{if and(or(containsValue(parameters._azure_docker_stage_params, pair.key), containsValue(parameters._general_params, pair.key)), not(containsValue(parameters._ignore_params, pair.key)))}}:
${{pair.key}}: ${{pair.value}}
dockerRunCommand: "docker run --name ${{parameters.appName}} -d -p ${{parameters.hostPort}}:${{parameters.containerPort}} ${{parameters.appName}}:${{parameters.buildTag}}"
dockerRunPostSteps:
- script: |
status_code=$(curl --write-out %{http_code} --silent --output /dev/null http://localhost:${{parameters.hostPort}}/)
if [[ "$status_code" -ne 200 ]] ; then
echo "Received status $status_code" Expected 200; exit 1
else
exit 0
fi
displayName: "Smoke Test: WebApp"
name: SmokeTest_App
workingDirectory: ${{parameters.workingDirectory}}
- script: |
status_code=$(curl --write-out %{http_code} --silent --output /dev/null http://localhost:${{parameters.hostPort}}/api/capital-of-ukraine)
if [[ "$status_code" -ne 200 ]] ; then
echo "Received status $status_code" Expected 200; exit 1
else
exit 0
fi
displayName: "Smoke Test: API"
name: SmokeTest_Api
workingDirectory: ${{parameters.workingDirectory}}
- script: |
status_code=$(curl --write-out %{http_code} --silent --output /dev/null http://localhost:${{parameters.hostPort}}/api/this-does-not-exist)
if [[ "$status_code" -ne 404 ]] ; then
echo "Received status $status_code" Expected 404; exit 1
else
exit 0
fi
displayName: "Smoke Test: 404"
name: SmokeTest_404
workingDirectory: ${{parameters.workingDirectory}}