-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
151 lines (135 loc) · 5.18 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
trigger:
branches:
include:
- master
paths:
include:
- MyProject/MyProject.ReportExecutor/*
- MyProject/MyProject.Business/*
pool:
vmImage: 'ubuntu-latest'
variables:
BuildConfiguration: 'Release'
projectPath: '**/MyProject.ReportExecutor.csproj'
testProjectPath: '**/MyProject.@(ReportExecutor|Business)*.Test.csproj'
ImageName: 'myprojectreportexecutor'
stages:
- stage: CI
displayName: 'CI stage'
jobs:
- job: Build
displayName: 'Build for MyProject'
steps:
# Add all the tasks you need to build your project
- task: WhateverTask@1
displayName: 'Build MyProject'
# all the parameters you need
- task: Docker@2
displayName: 'Build MyProject image'
inputs:
repository: '$(ImageName)'
command: build
Dockerfile: MyProject/Dockerfile
tags: $(Build.BuildId)
- task: Docker@2
displayName: 'Save image to TAR'
inputs:
repository: '$(ImageName)'
command: save
arguments: '--output $(build.artifactstagingdirectory)/$(ImageName).image.tar $(ImageName):$(Build.BuildId)'
addPipelineData: false
- task: PublishPipelineArtifact@1
displayName: 'Publishing Image as Pipeline Artifact'
inputs:
path: $(build.artifactstagingdirectory)
artifact: ContainerImage
- stage: CDDev
displayName: 'CD stage for DEV'
jobs:
- deployment: Dev
displayName: 'Deploy to DEV'
environment: MyProject-DEV
strategy:
runOnce:
deploy:
steps:
- task: Docker@2
displayName: 'Load Image from Tar'
inputs:
command: load
arguments: '--input $(Pipeline.Workspace)/ContainerImage/$(ImageName).image.tar'
- task: Docker@2
displayName: 'ReTag Image with ACR Name - BuildId'
inputs:
containerRegistry: MyProjectACRdev # This comes from the Service Connections
repository: '$(ImageName)'
command: tag
arguments: '$(ImageName):$(Build.BuildId) $(ContainerRegistryNameDev)/$(ImageName):$(Build.BuildId)'
- task: Docker@2
displayName: 'Push Image to ACR'
inputs:
containerRegistry: MyProjectACRdev
repository: '$(ImageName)'
command: push
tags: $(Build.BuildId)
# Add any other deployment task you need, for example a Kubectl task to deploy to Kubernetes
- stage: CDUat
displayName: 'CD stage for UAT'
jobs:
- deployment: Uat
displayName: 'Deploy to UAT'
environment: MyProject-UAT
strategy:
runOnce:
deploy:
steps:
- task: Docker@2
displayName: 'Load Image from Tar'
inputs:
command: load
arguments: '--input $(Pipeline.Workspace)/ContainerImage/$(ImageName).image.tar'
- task: Docker@2
displayName: 'ReTag Image with ACR Name - BuildId'
inputs:
containerRegistry: MyProjectACRuat # This comes from the Service Connections
repository: '$(ImageName)'
command: tag
arguments: '$(ImageName):$(Build.BuildId) $(ContainerRegistryNameUAT)/$(ImageName):$(Build.BuildId)'
- task: Docker@2
displayName: 'Push Image to ACR'
inputs:
containerRegistry: MyProjectACRuat
repository: '$(ImageName)'
command: push
tags: $(Build.BuildId)
# Add any other deployment task you need, for example a Kubectl task to deploy to Kubernetes
- stage: CDProd
displayName: 'CD stage for PROD'
jobs:
- deployment: Prod
displayName: 'Deploy to PROD'
environment: MyProject-PROD
strategy:
runOnce:
deploy:
steps:
- task: Docker@2
displayName: 'Load Image from Tar'
inputs:
command: load
arguments: '--input $(Pipeline.Workspace)/ContainerImage/$(ImageName).image.tar'
- task: Docker@2
displayName: 'ReTag Image with ACR Name - BuildId'
inputs:
containerRegistry: MyProjectACRprod # This comes from the Service Connections
repository: '$(ImageName)'
command: tag
arguments: '$(ImageName):$(Build.BuildId) $(ContainerRegistryNamePROD)/$(ImageName):$(Build.BuildId)'
- task: Docker@2
displayName: 'Push Image to ACR'
inputs:
containerRegistry: MyProjectACRprod
repository: '$(ImageName)'
command: push
tags: $(Build.BuildId)
# Add any other deployment task you need, for example a Kubectl task to deploy to Kubernetes