Skip to content

Commit 1c3acd4

Browse files
author
Florian Wagner
authored
CI/CD Multi Stage Pipeline Examples (#38)
* Example for CI/CD pipelines Signed-off-by: Florian Wagner <[email protected]> * Split into Templates and Environments Signed-off-by: Florian Wagner <[email protected]> * Add CI and PR pipelines for IaC, Bot & LUIS Signed-off-by: Florian Wagner <[email protected]>
1 parent 958b700 commit 1c3acd4

File tree

15 files changed

+695
-0
lines changed

15 files changed

+695
-0
lines changed

AzureDevOps/CICDExamples/bot.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
### Bot Logic Continuous Integration and Deployment
2+
###
3+
### This pipeline will run:
4+
### - on PR on master within GeoBot/ (LUIS or Bot change), but will only train and publish Bot Code changes to Stage
5+
### - on CI on master within GeoBot/ (LUIS or Bot change), will train and publish Bot Code to Stage and then on Prod
6+
###
7+
### To introduce manual intervention before deploying to Stage and or Prod environment see here:
8+
### https://docs.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass
9+
###
10+
### Following Variable Groups have to be in place:
11+
###
12+
### SubscriptionDetails:
13+
### - ServicePrincipalID (Client/App ID)
14+
### - ServicePrincipalSecret (Client Secret)
15+
### - TenantId (AAD Id)
16+
### - SubscriptionId (Azure Subscription)
17+
###
18+
### StateStoreStage & StateStoreProd:
19+
### - TFStateRG (Resource Group for Terraform state)
20+
### - TFStateStA (Terraform state store storage account)
21+
### - TFStateLoc (Terraform state store storage account and resource group location)
22+
###
23+
### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
24+
resources:
25+
containers:
26+
- container: geobotagent
27+
image: h2floh/geobotagent
28+
29+
# CI trigger
30+
trigger:
31+
branches:
32+
include:
33+
- master
34+
paths:
35+
include:
36+
- GeoBot
37+
38+
# PR builds
39+
pr:
40+
branches:
41+
include:
42+
- master
43+
paths:
44+
include:
45+
- GeoBot
46+
47+
stages:
48+
- template: stages/bot.yaml # Template reference
49+
parameters:
50+
environment: Stage
51+
52+
- template: stages/bot.yaml # Template reference
53+
parameters:
54+
environment: Prod

AzureDevOps/CICDExamples/destroy.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
### DESTROY THE STAGING AND PRODUCTION ENVIRONMENT
2+
###
3+
### This pipeline is to clean up fully the
4+
### Staging (Environment: Stage) and Production (Environment: Prod)
5+
###
6+
###
7+
### Has to be started manually, no triggers are set up
8+
###
9+
### Following Variable Groups have to be in place:
10+
###
11+
### SubscriptionDetails:
12+
### - ServicePrincipalID (Client/App ID)
13+
### - ServicePrincipalSecret (Client Secret)
14+
### - TenantId (AAD Id)
15+
### - SubscriptionId (Azure Subscription)
16+
###
17+
### StateStoreStage & StateStoreProd:
18+
### - TFStateRG (Resource Group for Terraform state)
19+
### - TFStateStA (Terraform state store storage account)
20+
### - TFStateLoc (Terraform state store storage account and resource group location)
21+
###
22+
### BotConfigStage & BotConfigProd:
23+
### - BotName (Name of the Bot)
24+
### - Domain (Custom Domain name for the Bot)
25+
### - BotRegions (Azure Regions for the Bot PowerShell Array format)
26+
### - BotGlobalLocation (Azure Regions for global resources)
27+
### - PFXImportPassword (PFX file import password for SSL Bot Certificate)
28+
###
29+
### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
30+
resources:
31+
containers:
32+
- container: geobotagent
33+
image: h2floh/geobotagent
34+
35+
# No CI trigger
36+
trigger: none
37+
38+
# No PR trigger
39+
pr: none
40+
41+
stages:
42+
- stage: DestroyStage
43+
displayName: 'Destroy Staging Environment'
44+
dependsOn: []
45+
jobs:
46+
- template: stages/jobs/destroy.yaml # Template reference
47+
parameters:
48+
environment: Stage
49+
50+
- stage: DestroyProd
51+
displayName: 'Destroy Production Environment'
52+
dependsOn: DestroyStage
53+
jobs:
54+
- template: stages/jobs/destroy.yaml # Template reference
55+
parameters:
56+
environment: Prod

AzureDevOps/CICDExamples/iac.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
### INFRASTRUCTURE Continuous Deployment
2+
###
3+
### This pipeline will run:
4+
### - on PR on master within Deploy/IaC (Terraform configuration), but will only deploy infrastructure changes to Stage
5+
### - on CI on master within Deploy/IaC (Terraform configuration), will reapply infrastructure changes to Stage and then on Prod
6+
###
7+
### To introduce manual intervention before deploying to Stage and or Prod environment see here:
8+
### https://docs.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass
9+
###
10+
### Following Variable Groups have to be in place:
11+
###
12+
### SubscriptionDetails:
13+
### - ServicePrincipalID (Client/App ID)
14+
### - ServicePrincipalSecret (Client Secret)
15+
### - TenantId (AAD Id)
16+
### - SubscriptionId (Azure Subscription)
17+
###
18+
### StateStoreStage & StateStoreProd:
19+
### - TFStateRG (Resource Group for Terraform state)
20+
### - TFStateStA (Terraform state store storage account)
21+
### - TFStateLoc (Terraform state store storage account and resource group location)
22+
###
23+
### BotConfigStage & BotConfigProd:
24+
### - BotName (Name of the Bot)
25+
### - Domain (Custom Domain name for the Bot)
26+
### - BotRegions (Azure Regions for the Bot PowerShell Array format)
27+
### - BotGlobalLocation (Azure Regions for global resources)
28+
### - PFXImportPassword (PFX file import password for SSL Bot Certificate)
29+
###
30+
### Following Secure Files have to be in place:
31+
###
32+
### - sslcertstage.pfx (SSL for domain used in Staging)
33+
### - sslcert.pfx (SSL for domain used in Production)
34+
###
35+
### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
36+
resources:
37+
containers:
38+
- container: geobotagent
39+
image: h2floh/geobotagent
40+
41+
# CI trigger
42+
trigger:
43+
branches:
44+
include:
45+
- master
46+
paths:
47+
include:
48+
- Deploy/IaC
49+
50+
# PR builds
51+
pr:
52+
branches:
53+
include:
54+
- master
55+
paths:
56+
include:
57+
- Deploy/IaC
58+
59+
stages:
60+
- template: stages/iac.yaml # Template reference
61+
parameters:
62+
environment: Stage
63+
sslfilename: 'sslcertstage.pfx'
64+
65+
- template: stages/iac.yaml # Template reference
66+
parameters:
67+
environment: Prod
68+
sslfilename: 'sslcert.pfx'

AzureDevOps/CICDExamples/init.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
### INITIAL END-TO-END ENVIRONMENT CREATION
2+
###
3+
### This pipeline is for an initial end to end deployment of
4+
### Staging (Environment: Stage) and Production (Environment: Prod)
5+
### can also be used to reinitialize a environment
6+
###
7+
### Has to be started manually, no triggers are set up
8+
###
9+
### Following Variable Groups have to be in place:
10+
###
11+
### SubscriptionDetails:
12+
### - ServicePrincipalID (Client/App ID)
13+
### - ServicePrincipalSecret (Client Secret)
14+
### - TenantId (AAD Id)
15+
### - SubscriptionId (Azure Subscription)
16+
###
17+
### StateStoreStage & StateStoreProd:
18+
### - TFStateRG (Resource Group for Terraform state)
19+
### - TFStateStA (Terraform state store storage account)
20+
### - TFStateLoc (Terraform state store storage account and resource group location)
21+
###
22+
### BotConfigStage & BotConfigProd:
23+
### - BotName (Name of the Bot)
24+
### - Domain (Custom Domain name for the Bot)
25+
### - BotRegions (Azure Regions for the Bot PowerShell Array format)
26+
### - BotGlobalLocation (Azure Regions for global resources)
27+
### - PFXImportPassword (PFX file import password for SSL Bot Certificate)
28+
###
29+
### Following Secure Files have to be in place:
30+
###
31+
### - sslcertstage.pfx (SSL for domain used in Staging)
32+
### - sslcert.pfx (SSL for domain used in Production)
33+
###
34+
### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
35+
resources:
36+
containers:
37+
- container: geobotagent
38+
image: h2floh/geobotagent
39+
40+
# CI trigger
41+
trigger: none
42+
43+
# No PR trigger
44+
pr: none
45+
46+
stages:
47+
- template: stages/endtoend.yaml # Template reference
48+
parameters:
49+
environment: Stage
50+
sslfilename: 'sslcertstage.pfx'
51+
52+
- template: stages/endtoend.yaml # Template reference
53+
parameters:
54+
environment: Prod
55+
sslfilename: 'sslcert.pfx'

AzureDevOps/CICDExamples/luis.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
### LUIS NLP Continuous Integration and Deployment
2+
###
3+
### This pipeline will run:
4+
### - on PR on master within GeoBot/GeoBot/CognitiveModels (LUIS configuration), but will only train and publish LUIS changes to Stage
5+
### - on CI on master within GeoBot/GeoBot/CognitiveModels (LUIS configuration), will train and publish LUIS changes to Stage and then on Prod
6+
###
7+
### To introduce manual intervention before deploying to Stage and or Prod environment see here:
8+
### https://docs.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass
9+
###
10+
### Following Variable Groups have to be in place:
11+
###
12+
### SubscriptionDetails:
13+
### - ServicePrincipalID (Client/App ID)
14+
### - ServicePrincipalSecret (Client Secret)
15+
### - TenantId (AAD Id)
16+
### - SubscriptionId (Azure Subscription)
17+
###
18+
### StateStoreStage & StateStoreProd:
19+
### - TFStateRG (Resource Group for Terraform state)
20+
### - TFStateStA (Terraform state store storage account)
21+
### - TFStateLoc (Terraform state store storage account and resource group location)
22+
###
23+
### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
24+
resources:
25+
containers:
26+
- container: geobotagent
27+
image: h2floh/geobotagent
28+
29+
# CI trigger
30+
trigger:
31+
branches:
32+
include:
33+
- master
34+
paths:
35+
include:
36+
- GeoBot/GeoBot/CognitiveModels
37+
38+
# PR builds
39+
pr:
40+
branches:
41+
include:
42+
- master
43+
paths:
44+
include:
45+
- GeoBot/GeoBot/CognitiveModels
46+
47+
stages:
48+
- template: stages/luis.yaml # Template reference
49+
parameters:
50+
environment: Stage
51+
52+
- template: stages/luis.yaml # Template reference
53+
parameters:
54+
environment: Prod
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
### This is a template, can not be used as a root pipeline
2+
###
3+
### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
4+
parameters:
5+
environment: ''
6+
7+
stages:
8+
9+
- stage: BOT${{ parameters.environment }}
10+
displayName: '${{ parameters.environment }} updating Bot'
11+
condition: or(eq('${{ parameters.environment }}', 'Stage'), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
12+
variables:
13+
# This group must include following variables:
14+
# - ServicePrincipalID (Client/App ID)
15+
# - ServicePrincipalSecret (Client Secret)
16+
# - TenantId (AAD Id)
17+
# - SubscriptionId (Azure Subscription)
18+
- group: SubscriptionDetails
19+
# This group must include following variables:
20+
# - TFStateRG (Resource Group for Terraform state)
21+
# - TFStateStA (Terraform state store storage account)
22+
# - TFStateLoc (Terraform state store storage account and resource group location)
23+
- group: StateStore${{ parameters.environment }}
24+
25+
jobs:
26+
- deployment: BOT
27+
displayName: 'Deploying Bot .NET Core to ${{ parameters.environment }}'
28+
pool:
29+
name: Default
30+
demands:
31+
- docker
32+
container: geobotagent
33+
environment: ${{ parameters.environment }}
34+
strategy:
35+
runOnce:
36+
deploy:
37+
steps:
38+
- template: jobs/steps/bot.yaml # Template reference
39+
parameters:
40+
environment: ${{ parameters.environment }}

0 commit comments

Comments
 (0)