-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
89 lines (83 loc) · 2.99 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
# Docker
# Build a Docker image
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
tags:
include:
- '*.*'
pool:
vmImage: ubuntu-latest
resources:
- repo: self
variables:
tag: 'dashboard-$(Build.SourceBranchName)'
repoServiceConnection: 'akaDockerRegistryServiceConnection'
imageName: 'sagtestclient/aron-docker'
k8sNamespace: 'aka-dashboard'
azureSubscriptionEndpoint: 'aka-resource-manager-service-connection'
azureResourceGroup: 'apigw-dashboard'
kubernetesCluster: 'dashboard'
imagePullSecret: 'aron-docker-registry'
k8sServiceConnection: 'dashboard-aka-dashboard'
stages:
- stage: Build
displayName: Build image
jobs:
- job: BuildAndPublish
displayName: Build and Publish
steps:
- task: Docker@2
displayName: Build image
inputs:
repository: $(imageName)
command: build
dockerfile: '$(Build.SourcesDirectory)/Dockerfile'
tags: |
$(tag)
$(Build.BuildNumber)
- task: Docker@2
displayName: Push image to repo
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
inputs:
containerRegistry: $(repoServiceConnection)
repository: $(imageName)
command: push
tags: |
$(tag)
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
jobs:
- deployment: Deploy
displayName: Deploy job
environment: 'AronKaSAGapigwcicddashboard' #customize with your environment
strategy:
runOnce:
deploy:
steps:
- checkout: self
- task: KubernetesManifest@0
displayName: Create imagePullSecret
inputs:
action: createSecret
secretName: $(imagePullSecret)
namespace: $(k8sNamespace)
dockerRegistryEndpoint: $(repoServiceConnection)
kubernetesServiceConnection: $(k8sServiceConnection)
- task: Bash@3
displayName: insert tag into dashboard yaml
inputs:
targetType: filePath
filePath: '$(Build.SourcesDirectory)/insert_tag.bash'
arguments: '$(Build.SourcesDirectory)/dashboard_deployment.yaml $(tag)'
- task: Kubernetes@1
displayName: kubectl apply using configFile
inputs:
connectionType: Azure Resource Manager
azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
azureResourceGroup: $(azureResourceGroup)
kubernetesCluster: $(kubernetesCluster)
namespace: $(k8sNamespace)
command: apply
useConfigurationFile: true
configuration: '$(Build.SourcesDirectory)/dashboard_deployment_modified.yaml'