-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathazure-pipelines.yml
117 lines (97 loc) · 4.69 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
# dina-local-deployment pipeline
trigger:
- master
parameters:
- name: pushACR
displayName: Push to Azure Container Registry (ACR)
type: boolean
default: false
name: dina-local-deployment pipeline
pool:
vmImage: ubuntu-latest
variables:
AZ_SC: $(ServiceConnection)
AZ_ACR: $(ContainerRegistry)
HELM_PACKAGE: $(Pipeline.Workspace)/helm/output/
steps:
- task: HelmDeploy@0
name: setupHelm
inputs:
command: 'package'
chartPath: 'helm'
destination: ${{ variables.HELM_PACKAGE }}
- script: |
version=$(helm inspect chart helm/ | grep -Po '(?<=version:\s)[0-9.]+')
name=$(helm inspect chart helm/ | grep -Po '(?<=name:\s)[^\s]+')
package=${{ variables.HELM_PACKAGE }}"${name}-${version}.tgz"
echo "##vso[task.setvariable variable=HELM_FILE;]$package"
displayName: 'Setting Helm information for Azure Container Registry'
- task: AzureCLI@2
displayName: Login and push to Azure Container Registry
condition: ${{ eq(parameters.pushACR, true) }}
inputs:
connectedServiceNameARM: ${{ variables.AZ_SC }}
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
az acr login --name ${{ variables.AZ_ACR }}.azurecr.io
echo $HELM_FILE
helm push $HELM_FILE oci://${{ variables.AZ_ACR }}.azurecr.io/helm
# - script: |
# sudo sh -c "echo '192.19.33.9 dina.local' >> /etc/hosts"
# sudo sh -c "echo '192.19.33.9 api.dina.local' >> /etc/hosts"
# sudo sh -c "echo '192.19.33.9 keycloak.dina.local' >> /etc/hosts"
# displayName: 'Setting up hosts name'
# - script: |
# sudo apt-get install wget libnss3-tools -y
# wget https://github.com/FiloSottile/mkcert/releases/download/v1.4.3/mkcert-v1.4.3-linux-amd64
# sudo chmod +x mkcert-v1.4.3-linux-amd64
# sudo mv mkcert-v1.4.3-linux-amd64 /usr/bin/mkcert
# mkcert --install
# mkcert -cert-file $(Pipeline.Workspace)/s/certs/dina-local-cert.pem -key-file $(Pipeline.Workspace)/s/certs/dina-local-key.pem "dina.local" "api.dina.local" "keycloak.dina.local"
# displayName: Setting up certificates
# - bash: docker compose -f docker-compose.base.yml -f docker-compose.local.yml up&
# displayName: 'Start DockerCompose'
# - bash: |
# until [ "$response" = "303" ]; do
# >&2 echo "Attempting to Reach Keycloak Server ..."
# >&2 echo "Response Code: $(curl --head -X GET --write-out %{http_code} --silent --output /dev/null https://dina.local/auth)"
# response=$(curl --head -X GET --write-out %{http_code} --silent --output /dev/null https://dina.local/auth)
# sleep 1
# done;
# >&2 echo "Keycloak Server Reached!"
# displayName: 'Waiting for Keycloak ...'
# - bash: |
# token_res=$(curl -X POST --silent -u "dina-admin:dina-admin" -d "grant_type=password&username=dina-admin&password=dina-admin&client_id=dina-public&scope=openid" https://dina.local/auth/realms/dina/protocol/openid-connect/token)
# token_var=$(echo $token_res | grep -Po '"access_token":[^\,]*' | sed -e 's/\"access_token"://g' -e 's/\"//g')
# until [ "$response" = "200" ]; do
# >&2 echo "Attempting to Access Collection Module ..."
# >&2 echo "Response Code: $(curl -X GET --write-out %{http_code} --silent --output /dev/null -H "Content-Type: application/vnd.api+json" -H "Authorization: Bearer $token_var" https://dina.local/api/collection-api/material-sample)"
# response=$(curl -X GET --write-out %{http_code} --silent --output /dev/null -H "Content-Type: application/vnd.api+json" -H "Authorization: Bearer $token_var" https://dina.local/api/collection-api/material-sample)
# sleep 3
# done;
# >&2 echo "Collection Module Endpoint Accessed!"
# displayName: 'Verify Collection Module Connection ...'
# - script: |
# wget -c https://dlcdn.apache.org/jmeter/binaries/apache-jmeter-5.6.1.tgz
# tar -xf apache-jmeter-5.6.1.tgz
# displayName: 'Install the JMeter'
# - script: |
# apache-jmeter-5.6.1/bin/./jmeter -n -t jmeter/collection_api_module_testplan.jmx -l results/results.jtl -e -o jmeter_report -j jmeter.log
# echo Done
# displayName: 'Run JMeter'
# - bash: docker compose -f docker-compose.base.yml -f docker-compose.local.yml down
# displayName: 'Stop DockerCompose'
# - script: |
# wget https://raw.githubusercontent.com/Azure-Samples/jmeter-aci-terraform/main/scripts/jtl_junit_converter.py
# python3 jtl_junit_converter.py results/results.jtl results/results_junit.xml
# displayName: 'Convert and assemble report'
# - task: PublishTestResults@2
# inputs:
# testResultsFormat: 'JUnit'
# testResultsFiles: 'results/results_junit.xml'
# failTaskOnFailedTests: true
# displayName: 'Publish jMeter test results'
# - publish: jmeter_report
# artifact: JMeterResults
# displayName: 'Publich jMeter artifacts'