-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines-trisotech-container.yml
166 lines (138 loc) · 4.34 KB
/
azure-pipelines-trisotech-container.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# 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:
- none
resources:
webhooks:
- webhook: hook
connection: TrisotechHook
filters:
- path: container
value: kmcontainerregistry.azurecr.io/playground
variables:
- group: ml-artreg-trisotech-kmdp-p
- group: km-container-registry
- name: dockerRegistryServiceConnection
value: "mclmprod"
- name: tag
value: '$(Build.BuildId)'
- name: dockerfilePath
value: "$(Build.SourcesDirectory)/Dockerfile"
- name: targetImage
value: "kmd/playground"
- name: targetRegistry
value: "mclmprod.azurecr.io"
stages:
- stage: PullContainerImage
displayName: Pull image
jobs:
- job: Pull
displayName: Pull image
pool:
vmImage: ubuntu-latest
steps:
- task: CmdLine@2
displayName: 'Docker login to Trisotech interim registry'
inputs:
script: "echo '$(kmcr.password)' | docker login --username $(kmcr.username) --password-stdin kmcontainerregistry.azurecr.io"
- task: CmdLine@2
displayName: 'Pull container image'
inputs:
script: 'docker pull ${{ parameters.hook.container }}'
- task: Bash@3
displayName: Save image tar file
inputs:
targetType: 'inline'
script: |
docker image save -o $(Pipeline.Workspace)/image.tar ${{ parameters.hook.container }}
- task: PublishPipelineArtifact@1
displayName: Publish image to pipeline
inputs:
artifactName: container-image
targetPath: '$(Pipeline.Workspace)/image.tar'
# - stage: PublishGcp
# displayName: Push Image to Google Artifact Registry
# dependsOn:
# - PullContainerImage
# condition: succeeded()
# jobs:
# - job: Publish
# displayName: Publish
# pool:
# name: MCC Applications
# steps:
# - task: MCCVaultIntegration@1
# displayName: "MCC Vault Integration"
# name: mccvault
# inputs:
# vaultActionType: 'gcpCreds'
# gcpSecretType: 'token'
# GcpCredRoleset: '$(Vault.Roleset)'
# Namespace: '$(Vault.Namespace)'
# RoleId: '$(Vault.RoleId)'
# SecretId: '$(Vault.SecretId)'
# HostUri: 'vault.mayo.edu:8200'
# - task: CmdLine@2
# displayName: 'Docker Login to Google Artifact Registry'
# inputs:
# script: 'docker login -u oauth2accesstoken -p $(mccvault.VaultResult) https://$(GCR.Name)'
# - task: DownloadPipelineArtifact@2
# inputs:
# artifact: container-image
# path: '$(System.ArtifactsDirectory)/'
# - bash: |
# docker load --input $(System.ArtifactsDirectory)/image.tar
# displayName: Docker load image
# - bash: |
# docker image ls
# displayName: List images
# - task: CmdLine@2
# displayName: 'Adjust image tag'
# inputs:
# script: 'docker tag $(trisotechImage) $(GCR.Name)/km/playground:$(tag)'
# - bash: |
# docker image ls
# displayName: List images
# - bash: |
# docker push $(GCR.Name)/km/playground:$(tag)
# displayName: Publish to Google Artifact Registry
# - task: ImportExportVariables@1
# inputs:
# action: 'Export'
- stage: PublishAzure
displayName: Push Image to Azure Container Registry
dependsOn:
- PullContainerImage
condition: succeeded()
jobs:
- job: Publish
displayName: Publish
pool:
vmImage: ubuntu-latest
steps:
- task: DownloadPipelineArtifact@2
inputs:
artifact: container-image
path: '$(System.ArtifactsDirectory)/'
- bash: |
docker load --input $(System.ArtifactsDirectory)/image.tar
displayName: Docker load image
- task: CmdLine@2
displayName: 'Adjust image tag'
inputs:
script: 'docker tag ${{ parameters.hook.container }} $(targetRegistry)/$(targetImage):$(tag)'
- bash: |
docker image ls
displayName: List images
- task: Docker@2
displayName: 'Push to Azure Container Registry'
inputs:
containerRegistry: 'mclmprod'
repository: '$(targetImage)'
tags: '$(tag)'
command: 'push'
- task: ImportExportVariables@1
inputs:
action: "Export"