-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpipeline.yaml
More file actions
104 lines (103 loc) · 4.13 KB
/
Copy pathpipeline.yaml
File metadata and controls
104 lines (103 loc) · 4.13 KB
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
trigger:
- main
variables:
- template: 'pipelines/prod.yaml'
stages:
- stage: build
pool:
name: myAgentPool
demands:
- ImageOverride -equals ubuntu-22.04
displayName: 'Build'
jobs:
- deployment: 'build'
displayName: 'Build'
environment: 'build'
strategy:
runOnce:
deploy:
steps:
- checkout: self
fetchDepth: 0
persistCredentials: true
- pwsh: |
az bicep build --file "main.bicep"
displayName: 'Bicep Linter & Build'
- task: AzurePowerShell@5
displayName: 'Netbox'
inputs:
azureSubscription: '${{ variables.serviceConnection }}' # string. Alias: ConnectedServiceNameARM. Required. Azure Subscription.
ScriptType: 'InlineScript' # 'FilePath' | 'InlineScript'. Script Type. Default: FilePath.
pwsh: true # boolean. Use PowerShell Core. Default: false.,
azurePowerShellVersion: 'OtherVersion'
preferredAzurePowerShellVersion: '11.4.0'
Inline: |
Connect-AzContainerRegistry -Name '${{ variables.AzContainerRegistry }}'
$datenow = Get-date -format yyyyMMdd.hh.mm
Write-Host "##vso[build.updatebuildnumber]$datenow"
write-verbose "Building dockerfile." -verbose
try {
docker build . -t "${{ variables.AzContainerRegistry }}.azurecr.io/Contoso/netbox:$datenow"
docker push "${{ variables.AzContainerRegistry }}.azurecr.io/Contoso/netbox:$datenow"
} catch {
throw
}
- task: AzurePowerShell@5
displayName: 'Redis'
inputs:
azureSubscription: '${{ variables.serviceConnection }}' # string. Alias: ConnectedServiceNameARM. Required. Azure Subscription.
ScriptType: 'InlineScript' # 'FilePath' | 'InlineScript'. Script Type. Default: FilePath.
pwsh: true # boolean. Use PowerShell Core. Default: false.,
azurePowerShellVersion: 'OtherVersion'
preferredAzurePowerShellVersion: '11.4.0'
Inline: |
Connect-AzContainerRegistry -Name '${{ variables.AzContainerRegistry }}'
Remove-item Dockerfile -force
Rename-item RedisDockerfile -NewName Dockerfile
docker build . -t "${{ variables.AzContainerRegistry }}.azurecr.io/Contoso/redis:7-alpine"
docker push "${{ variables.AzContainerRegistry }}.azurecr.io/Contoso/redis:7-alpine"
- stage: whatif
dependsOn: 'build'
pool:
name: myAgentPool
demands:
- ImageOverride -equals ubuntu-22.04
displayName: 'Whatif - Netbox'
variables:
- template: 'pipelines/prod.yaml'
- name: Environment
value: 'prod'
jobs:
- template: 'pipelines/validateDeployment.yml'
parameters:
AzureSubscription: '${{ variables.AzureSubscription }}'
Environment: '${{ variables.Environment }}'
ResourceGroupName: ${{ variables.ResourceGroupName }}
serviceConnection: '${{ variables.serviceConnection }}'
ImageVersion: '$(Build.BuildNumber)'
- stage: deploy
dependsOn: 'whatif'
pool:
name: myAgentPool
demands:
- ImageOverride -equals ubuntu-22.04
displayName: 'Deployment - Netbox'
variables:
- template: 'pipelines/prod.yaml'
- name: Environment
value: 'prod'
jobs:
- deployment: 'Netbox'
displayName: 'Deployment for Netbox'
environment: 'prod'
strategy:
runOnce:
deploy:
steps:
- template: 'pipelines/deploy.yml'
parameters:
AzureSubscription: '${{ variables.AzureSubscription }}'
Environment: '${{ variables.Environment }}'
ResourceGroupName: ${{ variables.ResourceGroupName }}
serviceConnection: '${{ variables.serviceConnection }}'
ImageVersion: '$(Build.BuildNumber)'