This repository has been archived by the owner on Jul 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devops-pipeline.yml
95 lines (88 loc) · 3.07 KB
/
devops-pipeline.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
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
variables:
azureSubscription: MFSubServiceConnection
acrDetails: '{"loginServer":"mfaksacr.azurecr.io", "id" : "/subscriptions/44e1dac0-0651-4835-8781-ee7b6e6f238f/resourceGroups/mfaks-spoke-rg/providers/Microsoft.ContainerRegistry/registries/mfaksacr"}'
kubernetesServiceConnection: 'MF Private AKS default'
stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build Job
pool:
name: 'SelfHostLinuxBuildAgents'
steps:
- task: Docker@0
displayName: 'Build API'
inputs:
azureSubscription: $(azureSubscription)
azureContainerRegistry: $(acrDetails)
dockerFile: testapi/Dockerfile
imageName: 'testapi:$(Build.BuildId)'
includeLatestTag: true
- task: Docker@0
displayName: 'Push API'
inputs:
azureSubscription: $(azureSubscription)
azureContainerRegistry: $(acrDetails)
action: 'Push an image'
imageName: 'testapi:$(Build.BuildId)'
includeLatestTag: true
- task: Docker@0
displayName: 'Build MVC'
inputs:
azureSubscription: $(azureSubscription)
azureContainerRegistry: $(acrDetails)
dockerFile: testmvc/Dockerfile
imageName: 'testmvc:$(Build.BuildId)'
includeLatestTag: true
- task: Docker@0
displayName: 'Push API'
inputs:
azureSubscription: $(azureSubscription)
azureContainerRegistry: $(acrDetails)
action: 'Push an image'
imageName: 'testmvc:$(Build.BuildId)'
includeLatestTag: true
- bash: |
echo $YAMLFILE
echo $BUILDID
sed -i -E "s/mfaksacr\.azurecr\.io\/test(\w*):v[0-9]$*/mfaksacr.azurecr.io\/test\1:$BUILDID/g" $YAMLFILE
displayName: 'Update Build Id'
env:
YAMLFILE: deployall.yaml
BUILDID: $(Build.BuildId)
- task: PublishPipelineArtifact@1
displayName: 'Publish Pipeline Artifact'
inputs:
targetPath: deployall.yaml
artifact: kubeyaml
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
jobs:
- deployment: Deploy
displayName: Deploy Job
pool:
name: SelfHostLinuxDeployAgents
environment: Production
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@2
inputs:
artifactName: 'kubeyaml'
downloadPath: '$(System.ArtifactsDirectory)/kubeyaml'
- task: Kubernetes@0
displayName: 'kubectl apply'
inputs:
kubernetesServiceConnection: $(kubernetesServiceConnection)
command: apply
useConfigurationFile: true
configuration: '$(System.ArtifactsDirectory)/kubeyaml/deployall.yaml'