-
Notifications
You must be signed in to change notification settings - Fork 305
/
Copy pathazure-petstoreproductservice-ci-cd-to-aks-pipeline.yml
115 lines (104 loc) · 3.37 KB
/
azure-petstoreproductservice-ci-cd-to-aks-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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Deploy to Azure Kubernetes Service
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
branches:
include:
- main
paths:
include:
- petstore/petstoreproductservice/*
resources:
- repo: self
variables:
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: 'azurepetstoremecr'
imageRepository: 'petstoreproductservice'
containerRegistry: 'azurepetstoremecr.azurecr.io'
dockerfilePath: 'petstore/petstoreproductservice/Dockerfile'
tag: '$(Build.BuildId)'
imagePullSecret: '$(crImagePullSecretGlobalV2)'
stages:
- stage: Build
displayName: Build stage
jobs:
#- job: Analysis
# displayName: Security Analysis
# pool:
# vmImage: 'windows-latest'
# steps:
#- task: CredScan@2
# inputs:
# toolMajorVersion: 'V2'
- job: Build
displayName: Build App
pool:
vmImage: 'ubuntu-latest'
steps:
- script: echo -n -e "{\"version\":\"$(Build.BuildNumber) - $(tag)\"}" > petstore/petstoreproductservice/src/main/resources/version.json
- task: Maven@3
continueOnError: true
displayName: Build Spring Boot Jar
inputs:
mavenPomFile: 'petstore/petstoreproductservice/pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '8'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: 'petstore/petstoreproductservice/target/surefire-reports/TEST-*.xml'
codeCoverageToolOption: 'jaCoCo'
goals: 'package'
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
latest
- upload: manifests
artifact: manifests
- stage: Deploy
displayName: Deploy Stage
dependsOn: Build
jobs:
- deployment: Deploy
displayName: Deploy App
pool:
vmImage: 'ubuntu-latest'
environment: 'Development'
strategy:
runOnce:
deploy:
steps:
- task: KubernetesManifest@0
displayName: Deploy to Kubernetes cluster
inputs:
action: deploy
kubernetesServiceConnection: azurepetstoreservices-akscluster
namespace: ingress-basic
manifests: |
$(Pipeline.Workspace)/manifests/petstoreproductservice-deployment-everything-enabled.yml
$(Pipeline.Workspace)/manifests/petstoreproductservice-service-everything-enabled.yml
imagePullSecrets: |
$(imagePullSecret)
containers: |
$(containerRegistry)/$(imageRepository):$(tag)
- stage: Automation
displayName: Automation stage
jobs:
- job: Automation
displayName: Automation Testing
pool:
vmImage: 'windows-latest'
steps:
- task: TriggerPipeline@1
inputs:
serviceConnection: 'Automation'
project: '6b3206dd-90b3-40f6-a611-e5a1e5a13593'
Pipeline: 'Build'
buildDefinition: 'azure-petstoreautomation-regression-tests'
Branch: 'main'