forked from persiaAziz-zz/sap-hana-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yaml
113 lines (113 loc) · 4.44 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
# This Azure pipeline YAML contains tests to validate and verify the pull requests made for automated deployment of SAP landscape.
# This pipeline will only run all the tests if the PR is made from a branch of Azure/sap-hana repo.
# Branches from forked repositories will fail in the Azure provider authentication phase due to security reason
# A pipeline with no CI trigger
trigger: none
# Only trigger build when a PR is opened for code under sap-hana/deploy
pr:
branches:
include:
- master
paths:
include:
- deploy/*
exclude:
- README.md
variables:
- group: azure-config-variables
- group: azure-sap-hana-pipeline-secrets
stages:
- stage: SetEnv
jobs:
- job: prepareAgent
pool:
vmImage: "ubuntu-18.04"
steps:
- checkout: self
clean: "all"
path: "sap-hana"
persistCredentials: true
- script: |
pip install packaging
sudo -H pip install msrest==0.6.0
displayName: 'Install python tools'
###############################################################################
# This stage creates resources for below test cases: #
# - Below testcases are tested only with SLES12 SP5 #
# - createAllNew-HA: it creates all resources from scratch in HA Scenario #
# - createAllNew-SN: it creates all resources from scratch for single node #
# - reuseRG-SN: it only reuses an existing resource group for single node #
# - reuseVnet-SN: it only reuses an existing vnet from createAllNew-SN #
# - reuseNSG-SN: it only reuses an existing NSG from createAllNew-SN #
# - createAllNew-SN testcase will be tested again with below OS #
# - RHEL7.6 #
###############################################################################
- stage: CreatingResources
dependsOn: SetEnv
jobs:
- template: templates/job-template-allReuseCases.yaml
parameters:
osVersion: "SLES12"
osImage: '\"offer\": \"sles-sap-12-sp5\",
\"publisher\": \"SUSE\",
\"sku\": \"gen1\"'
- template: templates/job-template-per-os.yaml
parameters:
osVersion: "RHEL7"
osImage: '\"offer\": \"RHEL-SAP-HA\",
\"publisher\": \"RedHat\",
\"sku\": \"7.6\"'
#####################################################################
# This stage destroy resources created from all above test cases. #
# It will be triggered after stage CreatingResources is finished. #
# It will always be triggered, regardless the status of stage one - #
# success of fail #
# Tag "Delete=True" will be added to mark all resource groups for #
# scheduled deletion done by azure-pipelines-cleanup.yaml #
#####################################################################
- stage: DestroyingResources
dependsOn: CreatingResources
condition: or(succeededOrFailed(), always())
jobs:
- job: cleanUp
steps:
- script: |
az login --service-principal --user $(hana-pipeline-spn-id) --password $(hana-pipeline-spn-pw) --tenant $(landscape-tenant) --output none
os_list=(
SLES12
RHEL7
)
scenario_list=(
sap-allNew-SN
sap-allNew-HA
sap-reuseRG-SN
sap-reuseVNET-SN
sap-reuseNSG-SN
)
for scenario in "${scenario_list[@]}"
do
for os in "${os_list[@]}"
do
rg_list+=("${scenario}-${os}-$(Build.BuildId)")
done
done
for rg in "${rg_list[@]}"
do
echo $rg
if $(az group exists -n $rg); then
az group update --resource-group $rg --set tags.Delete=True
az group delete -n $rg --no-wait -y
fi
done
displayName: 'Clean up'
env:
TF_VAR_azure_service_principal_id: $(hana-pipeline-spn-id)
TF_VAR_azure_service_principal_pw: $(hana-pipeline-spn-pw)
AZURE_CLIENT_ID: $(hana-pipeline-spn-id)
AZURE_SECRET: $(hana-pipeline-spn-pw)
AZURE_TENANT: $(landscape-tenant)
AZURE_SUBSCRIPTION_ID: $(landscape-subscription)
ARM_CLIENT_ID: $(hana-pipeline-spn-id)
ARM_CLIENT_SECRET: $(hana-pipeline-spn-pw)
ARM_TENANT_ID: $(landscape-tenant)
ARM_SUBSCRIPTION_ID: $(landscape-subscription)